RulesPal
Chat
Rulebook
The Amazing Dr. Nim thumbnail

The Amazing Dr. Nim

The Amazing Dr. Nim Rulebook

Table of Contents

Table of Contents

  • Setup
    • Setting Up Dr. Nim for Each New Game
  • How to Play Against Dr. Nim
    • Letting Dr. Nim Go First
  • Variations on the Game
    • "Last Marble Loses" Games
  • Now for a Whole New Set of Games
    • "Last Marble Wins" Games
  • Still More Games to Play With Your Dr. Nim
  • Dr. Nim as a Computer Machine
  • Let's Write This Game in the Form of Equations
  • Dr. Nim and Computer Programming
  • Program to Play Dr. Nim Against a Person

Setup

Setting Up Dr. Nim for Each New Game

  1. Put the 15 marbles in the top row of the machine.
  2. Set the flip-flops so they look like the picture in the manual. In the manual's shorthand (see "Dr. Nim as a Computer Machine" below) the 15-marble starting setting is A, B, C̅ with the turn switch D̅ and the equalizer E̅ (see the table on page 9 of the manual).
  3. Flip the equalizer to the START position.

The machine has these parts, labelled on the manual's diagram: the flip-flops (three levers, left to right A, B and C), the TURN SWITCH (set to PLAYER or DR. NIM), the TRIGGER, the EQUALIZER (set to START or OFF), and a NEW GAME control.

How to Play Against Dr. Nim

  1. If you want to go first, flip the TURN SWITCH to PLAYER.
  2. You may take 1 or 2 or 3 marbles on each turn.
  3. The one who takes the LAST marble LOSES.
  4. Next, PUSH the TRIGGER once for each of the 1 or 2 or 3 marbles you may want to take.
  5. After your turn, flip the TURN SWITCH to DR. NIM ... Then push the TRIGGER only ONCE and Dr. Nim will take his turn.
  6. When he is finished, Dr. Nim will flip the TURN SWITCH back to PLAYER for your turn.
  7. Repeat steps 4 and 5 until only ONE MARBLE IS LEFT.

WHOEVER HAS TO TAKE THAT LAST MARBLE LOSES!

Letting Dr. Nim Go First

If you should want to let Dr. Nim go first, flip the TURN SWITCH to DR. NIM and play as above.

If you play correctly, you can beat THE AMAZING DR. NIM, but remember, DR. NIM hates to lose ... so don't make any mistakes.

Variations on the Game

You may play DR. NIM with any number of marbles. Only you must use different setups for the Flip-Flops. Here are the Starting Positions for some of the different numbers of marbles you may play with.

The manual shows the flip-flop positions as pictures. Its page 8 re-writes the same table in the shorthand explained under "Dr. Nim as a Computer Machine" below, and that shorthand is used here. A bar over a flip-flop letter means that flip-flop is in the open (steep) position shown in the picture. A bar over E means the equalizer is at START. No bar over E means the equalizer is OFF.

"Last Marble Loses" Games

Number of Starting MarblesStarting Flip-Flop PositionsStarting Equalizer Position
20 or 16 or 12A B̅ CE̅ (START)
19 or 15 or 11A B C̅E̅ (START)
18 or 14 or 10A B CE̅ (START)
*17 or 13 or 9Ā B CE̅ (START)
18 or 14 or 10Ā B C̅E (OFF)

You should be able to beat Dr. Nim for all these cases, whether you take the first turn or have Dr. Nim take the first turn. From this table you can figure out the starting settings for more than 20 marbles. If you don't put the equalizer in the correct starting position, and let Dr. Nim go FIRST, no matter how you play Dr. Nim will always win, except in the case marked with an *. For the * case, if you don't put the equalizer in the correct starting position, and let Dr. Nim go SECOND, no matter how you play Dr. Nim will always win. Perhaps the hardest game for you to win would be the * case with the equalizer in the correct starting position and with you taking the first turn.

NOTE: To play with more than 15 marbles, simply add the necessary number of marbles back up to the top row from those already played at the bottom. For example, to play with 20 marbles, put the 15 marbles in the top row, then after 5 have been played, put them back up in the top row for a total of 20.

Now for a Whole New Set of Games

We will now change the rule so that the one who TAKES THE LAST MARBLE WINS!

To do this a different starting arrangement for the Flip-Flops is used. Everything else is the same as for the above games. Here are the starting conditions.

"Last Marble Wins" Games

Number of Starting MarblesStarting Flip-Flop PositionsStarting Equalizer Position
*20 or 16 or 12Ā B CE̅ (START)
19 or 15 or 11A B̅ CE̅ (START)
18 or 14 or 10A B C̅E̅ (START)
17 or 13 or 9A B CE̅ (START)
17 or 13 or 9Ā B C̅E (OFF)

You should be able to beat Dr. Nim for all of these cases. As before, if you forget to put the Equalizer in the correct starting position and Dr. Nim goes first, then Dr. Nim will always win!

From the above table you can figure out starting settings for more than 20 marbles.

Still More Games to Play With Your Dr. Nim

  1. You may use Dr. Nim to play against another person. To do this, simply follow all the above rules, but leave the TURN SWITCH on PLAYER at all times.
  2. Another game is to watch Dr. Nim play against himself. To do this, flip the TURN SWITCH back to DR. NIM after each play. Call the first turn player DR. NIM Number 1 and the second turn player DR. NIM Number 2. Try this with the EQUALIZER in the START position. Then try the same game with the EQUALIZER in the OFF position. See who wins, DR. NIM Number 1, or DR. NIM Number 2, in each of these cases. Can you guess why this happens?

Dr. Nim as a Computer Machine

DR. NIM is a "binary digital computer" specially designed to play the game of NIM. For a machine of such a simple design, containing only 6 moving logic elements, it might be argued that the word "computer" is an exaggeration, but consider some of its capabilities:

  1. DR. NIM can repetitively count up to 4. (This is performed by the top 3 logic elements.)
  2. DR. NIM can make logical decisions dependent upon the states of his logic elements. (He can decide whether to take another marble on his turn, whether to change the TURN to PLAYER, etc., dependent upon how the other player has played.)
  3. DR. NIM can alter the states of his logic elements as the game progresses to represent the state of the game.
  4. DR. NIM can "remember" the state of the game between his own and his opponent's play.
  5. DR. NIM can gate impulses in the form of marbles to continue its play as required to play a winning game.

Counting, logical functions, altering internal states, memory, and gating impulses are all typical characteristics of a computer. They are combined in such a manner that the machine appears to play an "intelligent" game of NIM. By "intelligent" it is meant that it would be entirely reasonable for a person trying to win the game of NIM to play in an identical manner.

The word "digital" refers to the fact that the positions of the logic elements are always one of two possible positions which may be designated by the digits "0" and "1". Let us say, for example, that each of the 5 elements, other than the trigger button or the gating mechanism, is in the "0" position if it is to the right and in the "1" position if it is to the left. Also, let us say that the gating element is "0" if it is up and "1" if it is down. Now, any logical state of the machine may be described by giving the positions of its 6 elements as being "0" or "1".

A number system having only the digits "0" and "1" is called a binary system. Any logic element that can take on exactly 2 different states denoted by the binary digits "0" and "1" is called a binary logic element or flip-flop. As DR. NIM uses only binary logic elements, he may be properly called a binary digital computer.

Let us review DR. NIM's structure. He is made up of three Flip-Flops, the turn setting element, a Clock Pulser (the Trigger) and several different paths for the marbles to take. The marbles are analogous to the impulses that are carried through an electronic computer. The elements are like the memory of the computer. They are asked questions by the impulses and they are changed, dependent upon the answers.

Consider how these elements should be connected. Each Flip-Flop is a two-state device. It is either open to permit a marble to go through or it is closed and does not permit a marble to pass through, but makes it go to the next Flip-Flop. As we said above, DR. NIM is a binary digital computer, its logic elements having only two states.

Suppose we name the three Flip-Flops A, B, and C, with the left one A, the center one B and the right one C. Then, also, we could call the "turn" switch D and the "equalizer" E.

If one of the Flip-Flops is open like this, for instance, the A Flip-Flop, then we will put a bar over the A, writing it Ā. Also, suppose we put a bar over the D when the "turn" switch is set to "DR. NIM", (D̅), and over the E when the "equalizer" is set to "start" (E̅).

Now we can re-write the starting positions table on Page 4 using these symbols instead of the pictures.

Number of Starting Marbles for "Last Marble Loses" GameStarting FLIP-FLOP PositionsStarting EQUALIZER Positions
20 or 16 or 12A B̅ CE̅
19 or 15 or 11A B C̅E̅
18 or 14 or 10A B CE̅
17 or 13 or 9Ā B CE̅
18 or 14 or 10Ā B C̅E

Now that we have this shorthand at our disposal, let us play a Game of NIM on paper. Suppose we play the game of "Last Marble Loses", with 15 marbles and DR. NIM goes first.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
15A B C̅D̅E̅

DR. NIM will take one and stop. (Note that D and E change states.) Then it's the player's turn and the settings are:

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
14A B CDE

Suppose he takes 2.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
13Ā B CDE
12A B̅ CD̅E

Now it's DR. NIM'S turn again and he will take 3.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
11A B C̅D̅E
10A B CD̅E
9Ā B CDE

The player takes 2.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
8A B̅ CDE
7A B C̅D̅E

This time DR. NIM will take 2.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
6A B CD̅E
5Ā B CDE

The Player takes 3.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
4A B̅ CDE
3A B C̅DE
2A B CD̅E

And DR. NIM will take 1.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
1Ā B CDE

The Player takes 1 and loses.

No. of Marbles LeftFlip-Flop SettingTurn Switch SettingEqualizer Setting
0A B̅ CDE

Let's Write This Game in the Form of Equations

Using the shorthand, each number of marbles left (M) corresponds to one setting of the flip-flops, turn switch (D) and equalizer (E):

15 = A B C̅ D̅ E̅
14 = A B C D E
13 = Ā B C D E
12 = A B̅ C D̅ E
11 = A B C̅ D̅ E
10 = A B C D̅ E
 9 = Ā B C D E
 8 = A B̅ C D E
 7 = A B C̅ D̅ E
 6 = A B C D̅ E
 5 = Ā B C D E
 4 = A B̅ C D E
 3 = A B C̅ D E
 2 = A B C D̅ E
 1 = Ā B C D E

The first thing we should notice is that the A, B & C Flip-Flops form a counter. Every fourth equation has the same setup for A, B & C. (For instance, whether there are 1, 5, 9, or 13 marbles left, the terms are Ā B C.)

The next thing we should notice is when DR. NIM decides he has had enough; that is when he changes the "turn" switch from "DR. NIM" to "Player". In our equations it would be when D̅ is changed to D. When there are 15, 10, 6 or 2 marbles left, he will take one more and stop.

Except for the first time, when there were 15 marbles, DR. NIM stopped when there was one more than a multiple of 4 marbles (when there were 1, 5 or 9).

This could all be expressed in a language called Boolean Algebra. It is the basis for all digital computer operation; whether it be an elementary one like DR. NIM or a giant electronic brain.

To illustrate the basic ideas involved in using Boolean Algebra, suppose we look back at the equations on Page 9. DR. NIM should end his turn when there is one marble left.

DR. NIM stopped when there were 1, or 5, or 9 or 14. That is, when the Flip-Flops were in the states described by the following equation:

STOP = Ā and B and C and D and E      (1)
Or
Ā and B and C and D and E             (5)
Or
Ā and B and C and D and E             (9)
Or
A and B and C and D and E             (14)

In the shorthand of Boolean Algebra, the word "OR" is replaced by the addition sign (+) and the word "AND" is replaced by the multiplication sign ( · ). Using this shorthand, then, the equations above may be rewritten as follows:

STOP = [Ā · B · C · D · E] + [Ā · B · C · D · E]
     + [Ā · B · C · D · E] + [A · B · C · D · E]

The second and third terms (groups) can be neglected since they are the same as the first term. Thus:

STOP = [Ā · B · C · D · E] + [A · B · C · D · E]

This brings out an interesting question. Why did DR. NIM stop on 14 (A · B · C · D · E) when in every other case, he kept going until he got to the Ā · B · C · D · E state, (which would be 13)? The answer is that DR. NIM, being a true gentleman, purposely makes a mistake on his first move to give the player a chance. That is what the "Equalizer" is for. If you forget to set it to "Start" and "DR. NIM" goes first, you can't win, except in the * case. In the * case if DR. NIM goes second and you forget to set it to "START", DR. NIM will always win.

Try writing more equations which describe DR. NIM's decision making process. For instance, you could, by following the same procedure, discover when DR. NIM will take another marble. By doing this you can see how the various Flip-Flops are connected by OR gates. (There are several different paths a marble could take and still accomplish the same end result.)

The key to beating DR. NIM is to do what he would do, before he gets a chance. If you study the equations and the machine carefully, you should learn how to beat THE AMAZING DR. NIM at his own game.

But DR. NIM could be designed by following the above discussion and working out the mathematical relationships as they have been here. In other words, you have been shown how a simple computer could be designed to satisfy a certain set of logical requirements. This is all that is done for a giant computer, except that there are many, many more equations and hence elements. But the basic principle is the same. A rather complete discussion of computer logic, including AND and OR gates, binary arithmetic and boolean algebra is given in the Advanced Manual for E.S.R.'s DIGI-COMP I.

Dr. Nim and Computer Programming

We may illustrate this point further by demonstrating a program of instructions that has been written to play the game of NIM in the manner that DR. NIM plays the game. The program has been written so that a person can easily obey the commands instead of having a machine follow them. It is convenient to write them mostly in English for a person. The same set of instructions could easily be coded for a computer with no change of logic, but they would be coded as numbers that the machine could follow rather than English statements.

The program has been written such that 4 numbers need be changed repeatedly and be remembered as the game progresses. We will call these numbers:

  • M = the number of marbles still left in the game (15 to start).
  • R = a remainder number needed by the program.
  • P = the number of marbles the PLAYER chooses on a given TURN.
  • N = the number of marbles the Program chooses on a given TURN.

In order to remember these numbers as the game progresses, get a blank sheet of paper and write the given letters at the top of 4 different columns, M, R, P and N.

During the course of the game several different numbers will be written in each column. Only the last number written in a column is taken to be the current value of the letter at the top of the column.

In following the program you must begin at Instruction 1 and follow the instructions consecutively downward until you are instructed to do otherwise. If you are instructed to jump to a different instruction out of sequence, do so and again follow the instructions consecutively downward from that point, etc.

Some of the instructions will tell you to change a number in a column, as for example, Instruction 7 says to, "Subtract 'P' from 'M' and write back in 'M'." This means to subtract the last number in column "P" from the last number in column "M" and write the result in column "M" under the last number.

Other instructions will ask a question and based on the answer will either tell you to jump to another instruction or to go on to the next instruction. For example, instruction 3 says, "If you wish to take the first turn go to instruction 6." If you do not want to take the first turn it is implied that you go to the next instruction, instruction 4.

It is very easy to make an error following the instructions, either by forgetting to write something down or by going to the wrong instruction. You will also be impressed with how tedious the procedure is and what a great number of instructions must be followed to play this game. Of course, the computer can follow a lengthy tedious set of instructions very rapidly and never make a mistake. This is one of the great advantages of the machine.

Program to Play Dr. Nim Against a Person

(Whoever takes last marble, loses.)

Instruction NumberInstruction
1Let's start a new game with 15 marbles.
2Write a 15 in Column "M" and a 2 in Column "R".
3If you wish to take first turn, go to Instruction 6.
4I will take 1 marble, write a "1" in Column N, subtract "1" from "M" and write back in Column "M". Also subtract "1" from "R" and write back in Column "R".
5If "M" is now zero go to Instruction 15. Otherwise continue.
6How many marbles do you wish to take? Write answer in Column "P".
7Subtract "P" from "M" and write back in "M".
8If "M" is now zero go to 16. Otherwise continue.
9If "P" is less than or equal to R go to 11.
10Add 4 to "R" and write back in "R".

In comparing DR. NIM with the computer program we would say that DR. NIM'S logic is built into the circuitry of the machine. As a result DR. NIM'S circuitry is simple by comparison to the general purpose computer with NIM-playing program, but DR. NIM has sacrificed generality for this simplicity.

It should now be clear that very lengthy and involved programs can be written, even to play such complicated games as checkers and chess. In the game of NIM it is possible to follow a simple mathematical rule to play correctly throughout. In checkers or chess no such simple rule exists.

11Subtract "P" from "R" and write back in "R".
12If "R" is not equal to zero go to 14. Otherwise continue.
13Write a "4" in "R". Go to 4.
14I will take "R" marbles. Write "R" in "N". Write "4" in "R". Subtract N from M. Go to 6.
15You win! Go to 1.
16You lose! Go to 1.