diff --git a/README.md b/README.md index 7400c60..2dcdc79 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # `cup` - CamelUp probability calculator -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. -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%. -(Numbers from running on a Ryzen 3700X.) +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. 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%. (Numbers from running on a Ryzen 3700X.) ``` Usage: diff --git a/cup.nim b/cup.nim index 09d2678..85c86c7 100644 --- a/cup.nim +++ b/cup.nim @@ -7,11 +7,12 @@ when isMainModule: b.init b.setState(config.state, []) b.diceRolled = config.diceRolled - echo b.showSpaces(1, 16) + let legScores = b.getLegScores + let gameScores = b.randomGames(1_000_000) + + echo b.showSpaces(1, 16) echo "\nCurrent leg probabilities:" echo legScores.showPercents() - - let gameScores = b.randomGames(1_000_000) echo "\nFull game probabilities (1M simulations):" echo gameScores.showPercents() diff --git a/ui.nim b/ui.nim index 5575d59..8bdc688 100644 --- a/ui.nim +++ b/ui.nim @@ -112,7 +112,7 @@ proc showPercents*(scores: ScoreSet): string = var bar = repeat(" ", 20) let percentage = round(pct * 100, 2) # populate the progress bar - let barFill = int(round(pct * 100 / 20)) + let barFill = int(round(pct * 20)) for i in 0 ..< barFill: bar[i] = '='