diff --git a/config.nims b/cup.nims similarity index 100% rename from config.nims rename to cup.nims diff --git a/game.nim b/game.nim index d9f1f83..f879ce7 100644 --- a/game.nim +++ b/game.nim @@ -121,9 +121,11 @@ proc display*(b: Board, start, stop: int) = proc setState*(b: var Board; state: GameState) = - for color, pos in b.camels: - if pos > 0: - b[pos].camels.clear() + for sq in b.squares.mitems: + if sq.camels.len > 0: + sq.camels.clear() + elif sq.tile.isSome: + sq.tile = none[Tile]() for (color, dest) in state.camels: # note that `camels` is ordered, as this determines stacking b[dest].camels.add(color) diff --git a/simulation.nim b/simulation.nim index 6179af1..38b4da6 100644 --- a/simulation.nim +++ b/simulation.nim @@ -1,4 +1,4 @@ -import cpuinfo, math, options, random, tables +import cpuinfo, math, options, random, sequtils, tables import combinators, game, fixedseq @@ -54,6 +54,11 @@ iterator legEndStates(b: Board): Board = proc getLegScores*(b: Board): ScoreSet = + # special case if all dice have been rolled + if allIt(b.diceRolled, it): + inc result[b.leader] + return result + for prediction in b.legEndStates: inc result[prediction.leader] diff --git a/test.nims b/test.nims new file mode 100644 index 0000000..ada9020 --- /dev/null +++ b/test.nims @@ -0,0 +1,4 @@ +--threads: on +--d: danger +--d: lto +--opt: speed