Any Browser Campaign

MasterMind, Variant 1, for HP-41CX
deutsche Version

Everybody should know "MasterMind", the logic game by Parker. One player provides a hidden code of colors or figures, and the other one's object is in as few as possible guesses to find out this sequence. The only hints are black and white markers. A black marker is given for a correct color (or figure) in the correct position, a white one determines a correct color (or figure) in an incorrect position.

In this program figures are used instead of colors, and the HP-41CX provides the hidden code and assesses the guess of the player. This has two advantages : first, you don't need a second willingly person, and second, the HP-41CX is guaranteed perfect in its assessment ! :-)

Example :

Given is a code consisting of four figures in the range from 0 through 5. Each figure is allowed to appear only once in the sequence. A possible flow of game could be as follows :

TryBlackWhiteCode
2 4 0 1
5
4
0
2 4 0 1
4
0
4
0 1 2 4
3
0
3
1 3 4 0
2
0
3
4 0 3 2
1
1
2
4 3 2 1

Course of Game :

On starting the program first a seed for the random number generator must be entered. The player can choose between a code of 4, 5, or 6 figures. When "POSITIONS ?" is displayed the desired number of positions must be entered. The range of figures can be chosen from 0 through 9, but always starts with 0 (inclusive) upwards. When "0-.. ?" appears in the display the user has to enter the upper boundary (inclusive). Now the player is asked, whether the figures are allowed to appear only once in the code or several times, too. If the figures are allowed to appear only once "Y" must be pressed, otherwise "N". Now the number of permutations is calculated and displayed. While the hidden sequence is generated "MIXING" is shown in the display. After this "CODE READY" is displayed.

Shortly later "INPUT" is displayed and the stopwatch starts running. Now it's the turn of the player to enter a code and to press R/S. The stopwatch pauses and the HP-41CX assesses the code. When this is accomplished the BEEP sounds and "RESULT :" is displayed. Pressing R/S first the number of black markers and then the number of the white ones are displayed. After this the prompt appears again and the next code is to be entered by the player.

On determining the exact code the required tries and time are displayed. If the player did give up - I can't imagine this ! ;-) - or runs out of time the hidden code can be revealed by XEQ 40. A code must be entered for authorization purposes. If the code is correct the sequence is displayed, otherwise all data are removed.

You want to know the code ??? ;-) . . . Simply read the source code carefully, then you will see, which code must be entered ! ;-)

Program Listing :

001 LBL "GAME5"
002  " MASTERMIND"
003  AVIEW
004  ,037
005  CLRGX
006  RCLFLAG
007  STO 08
008  "  "
009  RCL [
010  STO d
011  ,
012  SETSW
013  SIGN
014  STO 12
015  2
016  STO 13
017  3
018  STO 14
019  4
020  STO 15
021  5
022  STO 16
023  11
024  STO 01
025  16
026  STO 32
027  17
028  STO 31
029  23
030  STO 10
031  48
032  STO 23
033  STO 24
034  STO 25
035  STO 26
036  STO 27
037  STO 28
038 LBL 18
039  CF 22
040  " RNG-SEED :"
041  PROMPT
042  FC? 22
043  GTO 18
044  STO 09
045 LBL 07
046  CF 22
047  "  4-6 POS."
048  AVIEW
049  PSE
050  6
051  "POSITIONS ?"
052  PROMPT
053  FC? 22
054  GTO 07
055  INT
056  X>Y?
057  GTO 07
058  3
059  X<>Y?
060  X<=Y?
061  GTO 07
062  STO 33
063  ST+ 31
064  ST+ 32
065  DSE X
066   E3
067  /
068  STO 37
069 LBL 06
070  CF 22
071  "  FIGURES MAX."
072  "FROM 0-9"
073  AVIEW
074  PSE
075  9
076  " 0-.. ?"
077  PROMPT
078  FC? 22
079  GTO 06
080  INT
081  ABS
082  X>Y?
083  GTO 06
084  2
085  X<>Y?
086  X<=Y?
087  GTO 06
088  STO 36
089  ISG X
090  ""          (NOP)
091  STO 34
092 LBL 17
093  CF 23
094  "  FIGURES"
095  AVIEW
096  PSE
097  " ONLY ONCE "
098  "? Y/N :"
099  AON
100  PROMPT
101  AOFF
102  FC? 23
103  GTO 17
104  74
105  ATOX
106  X=Y?
107  SF 01
108  FS? 01
109  GTO 08
110  RCL 36
111  ISG X
112  ""           (NOP)
113  RCL 33
114  Y^X
115  GTO 10
116 LBL 08
117  ISG 36
118  ""           (NOP)
119  RCL 36
120  RCL 33
121  -
122   E3
123  /
124  ST+ 36
125   E
126 LBL 09
127  RCL 36
128  INT
129  *
130  DSE 36
131  GTO 09
132 LBL 10
133  " POSSIBLE "
134  "PERMUTATIONS:"
135  AVIEW
136  PSE
137  VIEW X
138  PSE
139  PSE
140 LBL 00
141  "  MIXING"
142  AVIEW
143 LBL 01
144  RCL 09
145  R-D
146  FRC
147  R-D
148  FRC
149  STO 09
150   E5
151  *
152  INT
153  RCL 34
154  MOD
155  FS? 01
156  GTO 03
157 LBL 05
158  ST+ IND 10
159  ISG 10
160  ""           (NOP)
161  ISG 37
162  GTO 01
163  GTO 04
164 LBL 03
165  5
166  +
167  FS? IND X
168  GTO 01
169  SF IND X
170  5
171  -
172  GTO 05
173 LBL 40
174  STOPSW
175  CLA
176  AON
177  STOP
178  AOFF
179  6
180  ALENG
181  XY?             not equal
182  GTO 41
183  ATOX
184  48
185  -
186  DATE
187  DOW
188  XY?             not equal
189  GTO 41
190  SF 00
191  "CODE : "
192  23
193  STO 35
194  STO 31
195  RCL 33
196  ST+ 31
197  GTO 42
198 LBL 43
199  AVIEW
200  STOP
201  GTO 41
202 LBL 04
203  CF 27
204  " CODE READY"
205  AVIEW
206  PSE
207  17
208  STO 00
209  RCL 08
210  STOFLAG
211 LBL 31
212  AON
213  TONE 7
214  RUNSW
215  " INPUT :"
216  PROMPT
217  STOPSW
218  AOFF
219  17
220  STO 35
221 LBL 13
222  ATOX
223  STO IND 35
224  ISG 35
225  ""           (NOP)
226  RCL 31
227  RCL 35
228  X<Y?
229  GTO 13
230  6
231  ST+ 31
232 LBL 11
233  23
234  STO 35
235  CLA
236 LBL 42
237  RCL IND 35
238  XTOA
239  ISG 35
240  ""           (NOP)
241  RCL 31
242  RCL 35
243  X<Y?
244  GTO 42
245  FS? 00
246  GTO 43
247  SIGN
248  STO 07
249  RCL IND 01
250  AROT
251  RCL IND 00
252  POSA
253  STO 04
254  X<0?
255  GTO 14
256  X=0?
257  GTO 15
258  RCL 04
259  STO 30
260  AROT
261  RCL 00
262  RCL 04
263  +
264  STO 05
265  RCL 32
266  RCL 05
267  X>Y?
268  XEQ 12
269  RCL IND 05
270  POSA
271  X=0?
272  GTO 20
273  RCL 05
274  12
275  -
276  STO 05
277  FS? IND 05
278  GTO 20
279  SF IND 05
280  GTO 16
281 LBL 14
282  ISG 00
283  ""           (NOP)
284  ISG 01
285  ""           (NOP)
286  RCL 32
287  RCL 00
288  X>Y?
289  GTO 30
290  GTO 11
291 LBL 15
292  ISG 02
293  ""           (NOP)
294  GTO 14
295 LBL 16
296  ISG 03
297  ""           (NOP)
298  GTO 14
299 LBL 12
300  RCL 33
301  ST- 05
302  RTN
303 LBL 20
304   E
305  ST+ 30
306  AROT
307  RCL IND 00
308  POSA
309  STO 06
310  ST+ 30
311  ST+ 04
312  RCL 33
313  DSE X
314  ""           (NOP)
315  RCL 30
316  X>Y?
317  GTO 14
318  RCL 06
319  AROT
320  RCL 00
321  RCL 04
322  +
323  RCL 07
324  +
325  STO 05
326  RCL 32
327  RCL 05
328  X>Y?
329  XEQ 12
330  RCL IND 05
331  POSA
332  X=0?
333  GTO 21
334  RCL 05
335  12
336  -
337  STO 05
338  FS? IND 05
339  GTO 21
340  SF IND 05
341  GTO 16
342 LBL 21
343  ISG 07
344  ""           (NOP)
345  GTO 20
346 LBL 30
347  ISG 29
348  ""           (NOP)
349  RCL 08
350  STOFLAG
351  17
352  STO 00
353  11
354  STO 01
355  BEEP
356  "  RESULT :"
357  AVIEW
358  STOP
359  FIX 0
360  CF 29
361  "BLACK : "
362  ARCL 02
363  AVIEW
364  PSE
365  "WHITE : "
366  ARCL 03
367  AVIEW
368  PSE
369  CLA
370  RCL 33
371  RCL 02
372  X=Y?
373  GTO 10
374  2,003
375  CLRGX
376  6
377  ST- 31
378  GTO 31
379 LBL 10
380  "TRIES : "
381  ARCL 29
382  AVIEW
383  PSE
384  FIX 4
385  SF 29
386  "  REQUIRED"
387  AVIEW
388  PSE
389  "TIME IN H.:"
390  AVIEW
391  PSE
392  RCLSW
393  VIEW X
394 LBL 41
395  RCL 08
396  STOFLAG
397  ,037
398  CLRGX
399  CLST
400  SETSW
401  CLA
402  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