A command-line dice simulator written in C++. Rolls a 6-sided die N times, saves the visual history to one file, and automatically generates statistics with a bar chart in another.
- Rolls a 6-sided die as many times as you choose
- Normal mode: saves each roll with its ASCII representation in
out/historial_*.txt - Fast mode: skips the ASCII art and only saves statistics, ideal for millions of rolls
- Generates
out/estadistica_*.txtwith a bar chart and the percentage for each face - Measures and displays the total simulation time in milliseconds
- Output files are timestamped so they don't overwrite each other between runs (Unix/epoch time)
History (out/historial_*.txt):
Rolled a 3!
╭───────────╮
│ ● │
│ ● │
│ ● │
╰───────────╯
Rolled a 1!
╭───────────╮
│ │
│ ● │
│ │
╰───────────╯
Statistics (out/estadistica_*.txt):
Roll statistics:
Face 1: |||||||||||..................................................................... 11%
Face 2: |||||||||||||||................................................................. 15%
Face 3: |||||||||||||||||............................................................... 17%
Face 4: |||||||||||||||||||............................................................. 19%
Face 5: ||||||||||||||||||.............................................................. 18%
Face 6: ||||||||||||||||||||............................................................ 20%
Total simulation time: 3 ms
- C++17 compiler or higher (g++ recommended)
- make program # Compiles the program (creates the "out" folder if it doesn't exist)
- make clean # Deletes all files inside the "out" folder
make (program)This generates the program.exe executable.
./program.exe # Runs the program
The program will ask you:
- The number of rolls you want to simulate
- Whether you want to use fast mode (
Y) or normal/slow mode (N)
Output files are automatically created in the out/ folder.
Dices/
├── include/
│ ├── dado.hh # DadoInfo struct, ASCII faces, and declarations
│ └── menu.hh # Console startup menu
├── src/
│ └── dado.cc # Implementation: roll die, statistics
├── out/ # Generated files (history and statistics)
├── main.cc # Entry point
└── Makefile
A Spanish version of this project is also available.
[View Spanish version](https://github.com/martinmol2007/dado_sim)Martin (@martinmol2007)