make use of prettier dislpays

This commit is contained in:
Joseph Montanaro 2021-07-14 22:05:03 -07:00
parent 20d6022828
commit 37991656b9
3 changed files with 11 additions and 6 deletions

View File

@ -4,6 +4,7 @@ This tool calculates probable outcomes for the board game CamelUp.
It can calculate all possible outcomes for a single game leg in about 5ms, so effectively instantaneously. It can calculate all possible outcomes for a single game leg in about 5ms, so effectively instantaneously.
Full-game calculations take a little bit longer and are not exact (since it isn't practical to simulate all possible full game states.) Full-game calculations take a little bit longer and are not exact (since it isn't practical to simulate all possible full game states.)
However it can easily simulate a million random games in about 80ms in the worst case, which should provide estimates accurate to within about 0.2%. However it can easily simulate a million random games in about 80ms in the worst case, which should provide estimates accurate to within about 0.2%.
(Numbers from running on a Ryzen 3700X.)
``` ```
Usage: Usage:

5
config.nims Normal file
View File

@ -0,0 +1,5 @@
--threads: on
--d: release
--opt: speed
--passC: -flto
--passL: -flto

11
cup.nim
View File

@ -1,5 +1,4 @@
import math, options, sequtils, random, sets import game, simulation, ui
import combinators, game, fixedseq, simulation, ui
when isMainModule: when isMainModule:
@ -8,11 +7,11 @@ when isMainModule:
b.init b.init
b.setState(config.state, []) b.setState(config.state, [])
b.diceRolled = config.diceRolled b.diceRolled = config.diceRolled
b.display(1, 5) echo b.showSpaces(1, 16)
let legScores = b.getLegScores let legScores = b.getLegScores
echo "Current leg probabilities:" echo "\nCurrent leg probabilities:"
legScores.display echo legScores.showPercents()
let gameScores = b.randomGames(1_000_000) let gameScores = b.randomGames(1_000_000)
echo "\nFull game probabilities (1M simulations):" echo "\nFull game probabilities (1M simulations):"
gameScores.display echo gameScores.showPercents()