The Museum of HP Calculators

# Queen Board for the HP-19C/HP-29C

This program is Copyright © 1977 by Hewlett-Packard and is used here by permission. This program was originally published in "HP-19C/HP-29C Applications Book", pages 52 through 54. This program was transcribed by Mark Lynch

This program is supplied without representation or warranty of any kind. Hewlett-Packard Company and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

## Overview

This game is based on the moves of a chess queen. A queen will be allowed to move only to the left, down, or diagonally to the left. The object of the game is to be the first player to move the queen to the lower left-hand corner of the chess board (square 158), by alternating moves between you and the calculator. You start by placing the queen on any square on the top row or right hand column. This is your first move. The play then alternates.

The playing board is numbered as follows:

 81 71 61 51 41 31 21 11 92 82 72 62 52 42 32 22 103 93 83 73 63 53 43 33 114 104 94 84 74 64 54 44 125 115 105 95 85 75 65 55 136 126 116 106 96 86 76 66 147 137 127 117 107 97 87 77 158 148 138 128 118 108 98 88

You tell the calculator your moves by keying in the number of the square you start on or move to. Press GSB 1 and the calculator responds with the square it moves to. Square 158 is the winning square.

The program does not check for illegal moves. If you win (by moving to square 158), the program will respond with 168 (the calculator acknowledges the loss by displaying a nonexistent square).

The program is in FIX 0 mode, for integer display.

## Reference:

This program is based on an HP-65 Users' Library program by Jacob R. Jacobs.

Some interesting comments on the theory of "Queen Board" may be found in: Gardner, M. "Mathematical Games", Scientific American, vol 236, no3., p. 134, March 1977.

## Instructions

 Step Instructions Input Data/Units Keys Output Data/Units 1 Key in the program. 2 Key in your starting position (first move). Move GSB 1 Calc's Move 3 Repeat step 2 until someone wins. Display of 158: calculator wins Display of 168: you win 4 To begin new game, repeat step 2 with new starting position

## Example

```

Keystrokes:                               Outputs:

55 GSB 1  -------------->      75.

(You start on 55, and the calculator, after deep and careful thought, moves
to 75).

97 GSB 1  -------------->      127.

(You respond with 97, and the calculator, showing no mercy moves to 127).

148 GSB 1 -------------->      158.

(You try 148, hoping the calculator's batteries run down before it can respond,
but no luck -- it wins by moving to 158).
```

## The Program

```       19C        29C
LINE   CODE       CODE      KEYS           COMMENTS
00
01  25 14 01   15 13 01   g LBL 1
02  16 13 00   14 11 00   f FIX 0
03     45 01      23 01   STO 1           Current position R1
04     13 00      12 00   GSB 0
05        01         01   1
06     16 61      14 71   f x=y
07     14 08      13 08   GTO 8
08        07         07   7
09     45 00      23 00   STO 0           7 --> R0
10  25 14 09   15 13 09   g LBL 9
11     55 01      24 01   RCL 1
12     55 00      24 00   RCL 0
13        23         33   EEX
14        01         01   1
15        51         61   x
16        41         51   +               10K + R1 --> R2
17     45 02      23 02   STO 2           Position good?
18     13 00      12 00   GSB 0
19        01         01   1
20     16 61      14 71   f x=y           Yes, recall R2
21     14 07      13 07   GTO 7
22     55 00      24 00   RCL 0           K + R2 --> R2
23  45 41 02   23 51 02   STO + 2         Position good?
24     55 02      24 02   RCL 2
25     13 00      12 00   GSB 0
26        01         01   1
27     16 61      14 71   f x=y           Yes, recall R2
28     14 07      13 07   GTO 7
29     55 00      24 00   RCL 0
30        23         33   EEX
31        01         01   1
32        51         61   x               10K + R2 --> R2
33  45 41 02   23 51 02   STO + 2
34     55 02      24 02   RCL 2           Position good?
35     13 00      12 00   GSB 0
36        01         01   1
37     16 61      14 71   f x=y           Yes, recall R2
38     14 07      13 07   GTO 7
39     25 45      15 23   g DSZ
40     14 09      13 09   GTO 9
41     55 01      24 01   RCL 1
42  25 14 08   15 13 08   g LBL 8
43        23         33   EEX             Default move
44        01         01   1               10 + R1 --> R1
45  45 41 01   23 51 01   STO + 1
46     55 01      24 01   RCL 1
47     25 13      15 12   g RTN
48  25 14 07   15 13 07   g LBL 7
49     55 02      24 02   RCL 2           Test for good position
50     25 13      15 12   g RTN
51  25 14 00   15 13 00   g LBL 0
52        01         01   1
53        05         05   5
54        08         08   8               158 = R2 ?
55     16 61      14 71   f x=y
56     14 06      13 06   GTO 6
57        03         03   3
58        01         01   1
59        31         41   -               127 = R2 ?
60     16 61      14 71   f x=y
61     14 06      13 06   GTO 6
62        01         01   1
63        31         41   -               126 = R2 ?
64     16 61      14 71   f x=y
65     14 06      13 06   GTO 6
66        05         05   5
67        01         01   1
68        31         41   -               75 = R2 ?
69     16 61      14 71   f x=y
70     14 06      13 06   GTO 6
71        02         02   2
72        31         41   -               73 = R2 ?
73     16 61      14 71   f x=y
74     14 06      13 06   GTO 6
75        02         02   2
76        09         09   9
77        31         41   -               44 = R2 ?
78     16 61      14 71   f x=y
79     14 06      13 06   GTO 6
80        03         03   3
81        31         41   -               41 = R2 ?
82     16 61      14 71   f x=y
83     14 06      13 06   GTO 6
84     25 13      15 12   g RTN
85  25 14 06   15 13 06   g LBL 6
86        01         01   1
87     25 13      15 12   g RTN

```

## Register Use

```R0  Indirect
R1  Used
R2  Used
```