Nimb for the HP-55

Back to main page | Email me at: Gene!


The program presented below will play the game of Nimb on the HP-55. It was written by Richard Emery and appeared in the V4N4P10 issue of the PPC Journal (April 1977). Thanks Richard!

The game of NIMB is an old calculator game. You start with 15 sticks in a pile and take turns removing 1, 2, or 3 sticks. The object is to leave the pile with only 1 stick remaining to make your opponent take the last stick.

Instructions:
0) Key the program in. Switch to RUN mode.
1) Store these constants: 55178 STO 1 (This is "BLISS" when viewed upside down), 3507.1 STO 2 (I.LOSE upside down).
2) Press the BST key and press R/S. 15 will be displayed (this is the number of sticks on the pile).
3) A positive display means that it is your turn. Remove either 1, 2, or 3 sticks from the pile (by entering 1, 2 or 3) and pressing R/S.
4) A negative number will be shown indicating the number left on the pile and that it is the HP-55's turn. Press R/S to give the machine a turn.
5) Continue with steps 3 and 4 until either BLISS or I.LOSE is displayed upside down. For a new game, goto step 2.


Program Listing: Note: The keycodes below that are negative are actually GTO commands as part of the conditional test. For example, the -45 at step 10 (listed with the instruction X = Y), tells the calculator to goto step 45 if X = Y). Email if you have any questions.
Line      Instruction  Keycode
01         FIX          24
02         0            00
03         1            01
04         5            05
05         R/S          84
06         -            51
07         1            01
08         X <> Y       22
09         g            32
10         X = Y       -45
11         CHS          42
12         R/S          84
13         CHS          42
14         1            01
15         -            51
16         3            03
17         X <> Y       22
18         f            31
19         X < = Y     -41
20         6            06
21         g            32
22         X = Y       -14
23         CLX          44
24         7            07
25         g            32
26         X = Y       -39
27         CLX          44
28         1            01
29         0            00
30         g            32
31         X = Y       -14
32         CLX          44
33         1            01
34         1            01
35         g            32
36         X = Y       -39
37         RDN          23
38         GTO 05      -05
39         2            02
40         -            51
41         GTO 05      -05
42         RCL          34
43         1            01
44         GTO 00       00
45         FIX          24
46         1            01
47         RCL          34
48         2            02
49         GTO 00       00

That's it!
Visitors since 8/6/97