Nimb for the HP-25

Back to main page | Email me at: Gene!


The program presented below will play the game of Nimb on the HP-25. It was written by R. L. Pekar and appeared in the V4N6P55 issue of the PPC Journal (June 1977). Thanks!

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 and press f PRGM.
1) Store these constants: -1 STO 0, 55178 STO 3 (This is "BLISS" when viewed upside down), 3507.1 STO 2 (I.LOSE upside down).
2) Set the display mode to FIX 0 and press R/S. 15 will be displayed (this is the number of sticks on the pile).
Note: The next two steps are exactly backwards from the HP-55 Nimb game on my site!
3) A negative 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 positive number will be shown indicating the number left on the pile and that it is the HP-25'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: Email if you have any questions.
Line      Instruction  Keycode
01         ENTER        31
02         f INT        14 01
03         g ABS        15 03
04         f X NE Y     14 61
05         GTO 22       13 22
06         g X = 0      15 71
07         GTO 22       13 22
08         4            04
09         X <> Y       21
10         f X > = Y    14 51
11         GTO 22       13 22
12         RCL 1        24 01
13         +            51
14         CHS          32
15         STO 1        23 01
16         g X < 0      15 41
17         GTO 46       13 46
18         g X = 0      15 71
19         GTO 46       13 46
20         R/S          74
21         GTO 25       13 25
22         RCL 0        24 00
23         f SQRT       14 02
24         GTO 46       13 46
25         RCL 1        24 01
26         1            01
27         -            41
28         g X = 0      15 71
29         GTO 48       13 48
30         4            04
31         /            71
32         f INT        14 01
33         4            04
34         *            61
35         1            01
36         +            51
37         f X = Y      14 71
38         GTO 40       13 40
39         GTO 42       13 42
40         1            01
41         -            41
42         CHS          32
43         STO 1        23 01
44         R/S          74
45         GTO 01       13 01
46         RCL 3        24 03
47         GTO 00       13 00
48         RCL 2        24 02
49         GTO 00       13 00

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