Rock-paper-scissors: Difference between revisions

m
Changed "Successors" to "Successor".
m (Changed "Successors" to "Successor".)
Line 3,533:
History = tuple[total: int; counts: CountTable[Choice]]
 
const SuccessorsSuccessor: array[Choice, Choice] = [Paper, Scissors, Rock]
 
func `>`(a, b: Choice): bool =
## By construction, only the successor is greater than the choice.
a == SuccessorsSuccessor[b]
 
proc choose(history: History): Choice =
Line 3,545:
for choice, count in history.counts.pairs:
if value <= count:
return SuccessorsSuccessor[choice]
dec value, count
 
Anonymous user