Any Browser Campaign

Number NIM Game for HP-41CX
deutsche Version

This is a variant of the well-known "NIM" game. In my version there were no sticks removed from heaps and not the one wins / looses, who is to take the last stick, but here the situation is a little bit more complicated (at least for human players - even if they know the strategy ;-) ).

In "Number NIM" alternately player and HP-41CX sum up numbers and the one wins (or looses), who reaches the final value. In minimum 1 must be added to the actual game value, maximal the chosen step width. You are obliged to move. You can choose between version "A" - he, who reaches the final value, wins - and version "B" - he, who reaches the final value, looses.

Example :

Assume version "A" is played - he wins, who reaches the final value. The final value is 10, maximal step width is 3. The player begins.

Input
Game Value
beginning of game
0
player
3
3
HP-41CX
3
6
player
2
8
HP-41CX
2
10
HP-41CX wins ! ;-)

Course of Game :

On starting the program the user has to choose between version "A", and "B", respectively. Now the final value must be entered, then the maximal step width. The player now has to decide, whether he or the HP-41CX begins. If the user wants to start the game he has to enter a "1", otherwise a "0".

Every integer value in the interval 1 up to the maximal step width (inclusive) can be entered (otherwise "CHEATED" is displayed). The HP-41CX first displays how much it adds and thereafter the result. Now the player enters the value he wants to add, and so on.

Program Listing :

001 LBL "GAME2"
002  " NUMBER NIM"
003  AVIEW
004  CF 29
005  CF 00
006  FIX 0
007   E-2
008  CLRGX
009   E-3
010  STO 09
011  ,001001
012  STO 07
013  "VERSION 'A'"
014  " OR 'B' ?"
015  AON
016  PROMPT
017  AOFF
018  ATOX
019  65
020  X=Y?
021  GTO 10
022  SF 00
023 LBL 10
024  "FINAL VAL. ?"
025  PROMPT
026  INT
027  ABS
028  STO 01
029  "MAX. STEP "
030  "WIDTH ?"
031  PROMPT
032  INT
033  ABS
034  STO 02
035  2
036  *
037  3
038  /
039  INT
040  ST+ 09
041  RCL 02
042  ISG X
043  ""          (NOP)
044  RCL X
045  RCL 01
046  X<>Y
047  /
048  INT
049  STO 05
050  RCL 01
051  RCL Z
052  MOD
053  STO 03
054  FS? 00
055  XEQ 12
056  RCL 05
057   E3
058  /
059   E-6
060  +
061  STO 05
062  CLST
063  "WHO BEGINS ?"
064  AVIEW
065  PSE
066  "  YOU = 1"
067  AVIEW
068  PSE
069  " HP-41CX = 0"
070  AVIEW
071  PSE
072  "   0 OR 1 ?"
073  AVIEW
074 LBL 02
075  GETKEY
076  X=0?
077  GTO 02
078  82
079  X=Y?
080  GTO 01
081 LBL 24
082  CF 22
083  VIEW 04
084  STOP
085  FC? 22
086  GTO 23
087  INT
088  STO 08
089  RCL 02
090  RCL 08
091  X>Y?
092  GTO 23
093  X<=0?
094  GTO 23
095  RCL 08
096  ST+ 04
097  VIEW 04
098  GTO 03
099 LBL 01
100  3,004
101  REGMOVE
102  RCL 04
103  X=0?
104  GTO 04
105  X<0?
106  XEQ 18
107  4,01
108  REGMOVE
109  XEQ 22
110  GTO 24
111 LBL 03
112  XEQ 05
113  RCL 06
114  RCL 04
115  X<Y?
116  GTO 08
117  X=Y?
118  GTO 04
119  ISG 05
120  XEQ 05
121  RCL 06
122  RCL 04
123  X=Y?
124  GTO 04
125  X>Y?
126  GTO 20
127  GTO 09
128 LBL 04
129  FS? 00
130  XEQ 13
131  RCL 01
132  RCL 04
133  X=Y?
134  GTO 07
135  FS? 00
136  XEQ 14
137  RCL 09
138  INT
139  ST+ 04
140  DSE 09
141  GTO 17
142  1,001
143  STO 09
144 LBL 17
145  RCL 07
146  INT
147  ST+ 05
148   E
149  RCL 07
150  INT
151  X=Y?
152  GTO 19
153  ISG 07
154  GTO 19
155 LBL 05
156  RCL 02
157  ISG X
158  ""           (NOP)
159  RCL 05
160  INT
161  *
162  RCL 03
163  +
164  STO 06
165  RTN
166 LBL 06
167  RCL 01
168  RCL 04
169  -
170  STO 10
171  XEQ 22
172  VIEW 01
173  PSE
174  "I AM SORRY,"
175  AVIEW
176  TONE 9
177  TONE 7
178  TONE 5
179  TONE 3
180  TONE 1
181  TONE 0
182  PSE
183  "  YOU LOST"
184  AVIEW
185  PSE
186  "  THE GAME"
187  GTO 16
188 LBL 07
189  FS? 00
190  XEQ 15
191  VIEW 04
192  PSE
193  "CONGRATULATE"
194  AVIEW
195  TONE 1
196  TONE 3
197  TONE 5
198  TONE 7
199  TONE 9
200  PSE
201  "  YOU WIN"
202  AVIEW
203  PSE
204  "  THE GAME"
205  GTO 16
206 LBL 15
207   E
208  ST+ 04
209  STO 10
210  XEQ 22
211  RTN
212 LBL 08
213  XEQ 05
214 LBL 09
215  FS? 00
216  XEQ 13
217  RCL 01
218  RCL 06
219  X=Y?
220  GTO 06
221  FS? 00
222  XEQ 14
223  XEQ 21
224  XEQ 22
225  6,004
226  REGMOVE
227  GTO 24
228 LBL 23
229  TONE 0
230  "  CHEATED"
231  AVIEW
232  PSE
233  GTO 24
234 LBL 12
235   E
236  ST- 03
237  RTN
238 LBL 13
239   E
240  ST- 01
241  RTN
242 LBL 14
243  E
244  ST+ 01
245  RTN
246 LBL 18
247  RCL 02
248  ISG X
249  ""           (NOP)
250  ST+ 04
251  ISG 05
252  RTN
253 LBL 19
254  XEQ 21
255  XEQ 22
256  GTO 24
257 LBL 20
258  ISG 05
259  GTO 03
260 LBL 21
261  RCL 06
262  RCL 04
263  -
264  ABS
265  STO 10
266  RTN
267 LBL 22
268  "HP-41CX: "
269  ARCL 10
270  AVIEW
271  PSE
272  RTN
273 LBL 16
274  AVIEW
275  SF 29
276  CF 00
277  FIX 4
278   E-2
279  CLRGX
280  CLST
281  CLA
282  END


Back to HP-41CX Selected (Game) Programs

Back to Natural Sciences and Mathematical Games

Back to the starting page

Kai Schröder, 30.5.2001