HP-41/42 Othello/Reversi Game

Back to main page Email me at: Gene!


This program will play the classic game of Othello otherwise known as Reversi. It originally appeared in the V8N3P13 and 14 of the PPC Journal and was written by Valentin Albillo. Thanks to Valentin wherever he is today! It's called Othello 2 (the program label is O2), because an original version was published in the PPC Technical Notes down in Australia. Anyone have a set of those I could copy? ;-)

The game features two levels, allows for either the diagonal or parallel opening, and either you or the calculator can go first. Optionally, a printer can be used which greatly facilitates playing the game. Note that the program has no random qualities to it at all. If you enter the same moves, the same game will be played. Strategy and skill are paramount here.

The program requires a SIZE of 130!

Running on the HP-41, a game in level 1 will take about 25 minutes if no printer, or 60 minutes with a printer. Level 2 takes about 1.5 hours if no printer and 2 hours if a printer is connected. (Remember, in addition to the printing time itself, the HP-41 continuously checks Flag 55 to see if a printer is attached, slowing down execution)

However, running the program on an HP-42S (which by default is about 2 times faster than an HP-41), takes about 12 minutes without printer or 30 minutes with a printer. However, if you have used the FAST program to speed up your HP-42 (see the article off my main page to try it - it works on early HP-42s but not on very late ones), you are running at about 4 times normal HP-41 speed, which makes the game quite pleasant to play. I like the dedicated HP-41 printer better than the infrared printer, however.

On the printout, the first player's pieces are printed as capital O's and and the second are checkerboard symbols. Initially, HP goes first and you second. This can be changed by setting flag 0. If flag 0 is clear, then the initial settings are used.

When you start this program, it will ask you if you want level 2. If so, do nothing; just press R/S. If you want level 1, press N in response to the prompt and press R/S.

It will then ask if you want to use the diagonal opening. If so, press R/S, otherwise press N and R/S. (I usually just press R/S here).

It will then ask if you want HP to go first. Since the player who goes first usually has a slight edge, the default is to allow HP to go first. If that is what you want, press R/S in response to the prompt. Otherwise, press N and press R/S.

Remember, it may take HP a while to figure out its move!

Play of the Game. When its HP's turn, it will show you its move along with how many pieces got "flipped". Then it will prompt you for your move. If you missed HP's move, just press the back-arrow key at the MOVE? prompt and HP's move will still be in the X register. Moves are described in an 8 x 8 grid with the numbers 1-8 going down the left side and also 1-8 going across the top. Coordinates used are row/column. For example, the top left corner would have the coordinate 11, while the bottom left corner would be 81, the top right would be 18 and the bottom right would be 88. These are printed with the board if you are using a printer.

If you enter an illegal move, it will display BAD MOVE. If HP can't move, it will display NO MOVE. If YOU can't move, enter 0 and press R/S.

To make the HP play against itself, at any time the program is stopped (usually the MOVE? prompt), change the status of flag 0, enter 0 and press R/S. HP will now play the opposite side of what it was. That is, if flag 0 is set, clear it and enter 0 and press R/S. Or vice versa.

To change the playing level, when the HP has stopped and is waiting for input, SF 09 for level 1, or CF 09 for level 2. This can be useful to play at level 1 early in the game to speed things up (the first couple of moves or so), then switch to level 2 for better play as the game progresses.

At the end of the game, the HP will display GAME OVER, HP-XX YOU-YY, and then either I WON or YOU WON, where XX will be the total number of pieces that HP has and YY the total number of pieces you have.

There are some instances when a game will end and the board is NOT full of pieces. In that situation, the counting of the pieces is not performed. It is suggested that you XEQ 06 to force a printing of the board (if it's not already printed) and manually count the pieces to determine the winner. This doesn't happen too often.


Sample Game. Here are the moves for a sample game, level 1, with HP going first. Format is HP/You. This is a good test to see if you entered the program correctly.

65/46, 33/64, 63/43, 66/72, 53/67, 81/42, 68/75, 36/35, 84/86, 51/31, etc.


Program Listing
Line      Instruction
01         LBL "O2"
02         FIX 0
03         CF 00
04         CF 29
05         CF 12
06         CLRG
07         1
08         STO 15
09         CHS
10         STO 16
11         9
12         STO 17
13         CHS
14         STO 18
15         +
16         STO 20
17         CHS
18         STO 19
19         X^2
20         STO 13
21         61
22         STO 14
23         11
24         STO 21
25         CHS
26         STO 22
27         .81881118
28         STO 23
29         .83866168
30         STO 25
31         .31381316
32         STO 26
33         .63663336
34         STO 27
35         .84855158
36         STO 29
37         .41481415
38         STO 30
39         .64655356
40         STO 31
41         .43463435
42         STO 32
43         .74755257
44         STO 33
45         .42472425
46         STO 34
47         .73766267
48         STO 35
49         .32372326
50         STO 36
51         .82877178
52         STO 37
53         .21281217
54         STO 38
55         .72772227
56         STO 39
57         "LEVEL 2?"
58         AON
59         CF 23
60         STOP
61         CF 09
62         FS?C 23
63         SF 09
64         "DIAG?"
65         STOP
66         RCL 15
67         STO 75
68         RCL 16
69         STO 85
70         FS?C 23
71         X <> Y
72         STO 74
73         X <> Y
74         STO 84
75         XEQ 06
76         "HP 1ST?"
77         STOP
78         AOFF
79         FS?C 23
80         GTO 00
81         65
82         GTO 08
83         LBL 14
84         CF 07
85         CLX
86         STO 06
87         23.04
88         STO 07
89         LBL 11
90         RCL IND 07
91         X = 0?
92         GTO 12
93         LBL 13
94         RCL 13
95         *
96         STO 11
97         INT
98         STO 10
99         CF 03
100        CF 08
101        XEQ 97
102        FC?C 04
103        XEQ 98
104        FS?C 08
105        GTO 14
106        RCL 11
107        FRC
108        X NE 0?
109        GTO 13
110        LBL 12
111        ISG 07
112        GTO 11
113        FC? 07
114        GTO 12
115        RCL 09
116        LBL 08
117        STO 10
118        CF 03
119        XEQ 97
120        LBL 14
121        CF 03
122        "I"
123        BEEP
124        XEQ 08
125        GTO 00
126        LBL 12
127        "NO"
128        LBL 60
129        "-> MOVE"
130        AVIEW
131        PSE
132        LBL 00
133        RCL 10
134        "MOVE?"
135        PROMPT
136        STO 10
137        X = 0?
138        GTO 14
139        SF 03
140        XEQ 97
141        "BAD"
142        FS?C 04
143        GTO 60
144        "YOU"
145        XEQ 08
146        GTO 14
147        LBL 08
148        "-> PLAY "
149        ARCL 10
150        AVIEW
151        23
152        STO 00
153        SIGN
154        LBL 31
155        STO 02
156        RCL IND 00
157        X = 0?
158        GTO 08
159        LBL 32
160        RCL 13
161        *
162        INT
163        RCL 10
164        X = Y?
165        GTO 00
166        RCL 13
167        ST* 02
168        LASTX
169        FRC
170        X NE 0?
171        GTO 32
172        LBL 08
173        SIGN
174        ST+ 00
175        GTO 31
176        LBL 00
177        "FLIP "
178        ARCL 01
179        AVIEW
180        RCL IND 00
181        RCL 02
182        *
183        INT
184        LASTX
185        FRC
186        RCL 13
187        *
188        FRC
189        +
190        RCL 02
191        /
192        STO IND 00
193        FC? 02
194        GTO 06
195        FS? 03
196        GTO 12
197        LBL 06
198        FC? 55
199        GTO 12
200        ADV
201        31
202        STO 00
203        45
204        STO 01
205        79
206        STO 02
207        2.01
208        STO 03
209        8
210        SKPCOL
211        49.056
212        STO 04
213        LBL 02
214        RCL 21
215        SKPCOL
216        X <> Y
217        ACCHR
218        ISG X
219        GTO 02
220        PRBUF
221        41.048
222        STO 05
223        LBL 09
224        RCL 04
225        ACCHR
226        RCL 17
227        SKPCOL
228        SF 12
229        LBL 10
230        RCL IND 05
231        RCL 15
232        +
233        RCL IND X
234        ACCHR
235        RCL 03
236        SKPCOL
237        ISG 05
238        GTO 10
239        PRBUF
240        ST+ 05
241        CF 12
242        ISG 04
243        GTO 09
244        ADV 
245        LBL 12
246        DSE 14
247        RTN
248        FC? 02
249        GTO 12
250        FS?C 03
251        XEQ 06
252        LBL 12
253        32
254        "GAME OVER"
255        41.118
256        AVIEW
257        0
258        LBL 07
259        RCL IND Y
260        +
261        ISG Y
262        GTO 07
263        2
264        /
265        X <> Y
266        RDN
267        ST- Z
268        +
269        ADV
270        "HP-"
271        ARCL X
272        "-> YOU-"
273        ARCL Y
274        AVIEW
275        PSE
276        X = Y?
277        STOP
278        ADV
279        "I"
280        X < Y?
281        "YOU"
282        "-> WON"
283        PROMPT
284        LBL 98
285        SF 07
286        SF 08
287        FS? 09
288        RTN
289        23
290        RCL 07
291        INT
292        2
293        MOD
294        LASTX
295        -
296        RCL 07
297        INT
298        +
299        X < Y?
300        RTN
301        3
302        10^X
303        /
304        +
305        STO 08
306        LBL 56
307        RCL IND 08
308        X = 0?
309        GTO 12
310        LBL 57
311        RCL 13
312        *
313        STO 12
314        INT
315        SF 06
316        SF 03
317        XEQ 99
318        FC?C 04
319        GTO 00
320        RCL 12
321        FRC
322        X NE 0?
323        GTO 57
324        LBL 12
325        ISG 08
326        GTO 56
327        RTN
328        LBL 00
329        RCL 06
330        RCL 08
331        INT
332        X > Y?
333        STO 06
334        X > Y?
335        CF 08
336        RCL 10
337        FC?C 08
338        STO 09
339        30
340        +
341        0
342        STO IND Y
343        119
344        STO 05
345        LBL 05
346        RCL IND 05
347        RCL 16
348        ST* IND Y
349        ST- 05
350        DSE 01
351        GTO 05
352        RTN
353        LBL 97
354        CF 06
355        LBL 99
356        SF 04
357        30
358        +
359        STO 00
360        RCL IND X
361        X NE 0?
362        RTN
363        FC? 06
364        STO 01
365        15.022
366        STO 02
367        119
368        STO 05
369        SIGN
370        FS? 00
371        CHS
372        FC? 03
373        CHS
374        STO 04
375        LBL 01
376        RCL 00
377        RCL IND 02
378        +
379        STO 03
380        RCL IND X
381        RCL 04
382        X NE Y?
383        GTO 12
384        LBL 03
385        LASTX
386        ST+ 03
387        RCL IND 03
388        RCL 04
389        X = Y?
390        GTO 03
391        CHS
392        X NE Y?
393        GTO 12
394        CF 04
395        FS? 06
396        RTN
397        STO IND 00
398        LBL 04
399        LASTX
400        ST- 03
401        RCL 00
402        RCL 03
403        X = Y?
404        GTO 12
405        STO IND 05
406        RCL 16
407        ST* IND Y
408        ST- 01
409        ST- 05
410        GTO 04
411        LBL 12
412        ISG 02
413        GTO 01
414        END