From ef134a9a6ea1a6623131ea4d63de61de5fae65d3 Mon Sep 17 00:00:00 2001 From: Joseph Montanaro Date: Fri, 22 Oct 2021 10:34:43 -0700 Subject: [PATCH] fix percentage bar fill --- cup.nim | 7 ++++--- ui.nim | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) 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] = '='