diff --git a/nim.py b/nim.py index 006f27b82d5e606a2cb5ee23b46a799a883eba59..81bba448578500dcc86ad46b24daa334d8ebaf75 100644 --- a/nim.py +++ b/nim.py @@ -68,7 +68,13 @@ def evaluate(heap_sizes): >>> evaluate([9, 12, 3, 7]) <Evaluation.LOSS: 'LOSS'> """ - return Evaluation.LOSS # Stub + if len(heap_sizes) > 1: + single_heap = convert_to_single_heap_using_builtin(heap_sizes[0], + heap_sizes[1]) + return evaluate([single_heap] + heap_sizes[2:]) + else: + return Evaluation.WIN if len(heap_sizes) == 0 or heap_sizes[0] == 0 \ + else Evaluation.LOSS def make_computer_move(position):