clear tiles as well as camels when setting state
This commit is contained in:
parent
4995a9388b
commit
d9efaf33e7
8
game.nim
8
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)
|
||||
|
@ -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]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user