# How are the 1s and 0s derived by the minimax algorithm for the game called "nim"?

I'm having trouble figuring out why the 1s and 0s are where they are in this game tree for the game Nim: There is a statement in the book that explains the numbers but it's still not clear to me,

In implementing minimax, we label each level in the search space according to whose move it is at that point in the game, MIN or MAX.

In the example, MIN is allowed to move first. Each leaf node is given a value of 1 or 0, depending on whether it is a win for MAX or for MIN. Minimax propagates these values up the graph through successive parent nodes according to the rule:

If the parent state is a MAX node, give it the maximum value among its children. If the parent is a MIN node, give it the minimum value of its children.

If I was to draw the tree by hand how would I know where to put the 1s and 0s?

• This isn't the game of nim. Apr 9 '17 at 17:45
• @YuvalFilmus This is the quote that is underneath that game tree; "Exhaustive minimax for the game of nim." Apr 10 '17 at 2:03
• Well, it just isn't the game of nim. You can look nim up on Wikipedia. Apr 10 '17 at 4:59
• @YuvalFilmus Then it's probably a mistake in the book. Apr 10 '17 at 14:24