A fantasy gambling game implemented in numerous novel languages. Performs a Monte Carlo simulation of 100,000 games. Prints a histogram of the results. Can use time to compare performance between. Includes a number of common data manipulation tasks:
- Run a procedure a large number times
- Generate die rolls a dynamic number of times
- Collect results into a sequence
- Generate a hash map histogram of that sequence
- Format and print the histogram
For languages which favor an imperative/procedural approach, iteration is used where it can maximize performance. Otherwise, a functional/data-oriented approach is used.
The rules of Dirty 30: The player starts the first round by rolling 30 dice. Any 6's are removed for the next round, wherein the remaining dice are rolled. The goal is to roll enough 6's to remove all the dice in the pool on or before the 30th roll. There are any number of gambling opportunities, such as betting on the number of rolls it will take to win, with larger payouts the earlier a correct prediction is made.
g++ -std=c++20 -O3 dirty30.cpp -o dirty30
time ./dirty30time clojure dirty30.cljtime sbcl --script dirty30.lispdmd -O -release dirty30.d
time ./dirty30time groovy dirty30.groovytime io dirty30.iotime janet dirty30.janettime node dirty30.jsnim cc -d:release dirty30.nim
time ./dirty30time nu dirty30.nutime python3 dirty30.pytime racket dirty30.rktcd dirty30-rs
cargo build --release
time ./target/release/dirty30-rsv -prod dirty30.v
time ./dirty30