The Museum of HP Calculators


Robot Trap for the HP-41C

This program was first published in the HP-41C Users' Library Solutions: Games by Hewlett-Packard and is used here by permission.

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

You move your android to any adjacent square on a 10 x 10 playing board studded with destructive force fields and up to 49 enemy robots in such a way as to lure the robots into their own electronic booby traps and save the android. The robots will always close on the android, moving to the square adjacent to their present position which is nearer to the row and column position of the android, and will team up to destroy him. The android, like the robots, is destroyed by moving into a force field, and the android is also destroyed by colliding with a robot. If robots collide all but one involved are destroyed. You choose the initial number of robots. The number of force fields is equal to the initial number of robots plus one. Even a few robots can be challenging and the more robots the more difficult. All initial positions are randomly generated.

If you move the android into a force field you will see "ZAP" then "TOO BAD". If you move the android into a robot you will see "STOMP" then "TOO BAD". If a robot stumbles into a force field you will see "STUMBLE". And, if robots hit, you will see "BUMP". Finally, if all robots are destroyed, you will see "YOU WIN".

The board is set up as below:

Board positions are denoted as x.y . The android shown is at 7,2. To move the android use the digits keys to specify directions as follows:

        1 - down and left       6 - right
        2 - down                7 - up and left
        3 - down and right      8 - up
        4 - left                9 - up and right
        5 - no movement

Note: Do not move off the board. Execution times at all points in the program increase with the initial number of robots.

Note: Requires 1 Memory Module on HP-41C

Instructions

Step

Instructions

Input Data/Units

Keys

Output Data/Units

1

Enter program

     

2

Initialize

 

[XEQ] RT 

SEED? 

3

Key in number between 0 and 1

seed 

[R/S]

NO.OF ROBOTS

 4

Key in the number of robots you wish.

num

[R/S]

SET SIZE(NNN)

5

Set size specified.   

[XEQ] SIZE(NNN) [R/S]

F.F. AT ()*

  (If size was already set at or above specified, the program will skip that prompt.)  

 

 

6

Continue pressing [R/S] to see the rest of the force field and robot Placements until the android placement appears.

 

[R/S]. . .

. . .

     

[R/S]

ANDROID: ()

7

 Move the android (only when "ANDROID: ( )" is in display.

direction

[R/S]

ROBOT AT ()

 8

Go to 6 to see the rest of the robot placements and new android placement.    

 

9

For a new game  

[E]

NO.OF ROBOTS

10

Go to step 4.    

 

 

 

 

 

 

 *

Force field placements are only output at the beginning of the game.

 

 

 

Example

   Keystrokes:          Display:
[XEQ] [ALPHA] 
SIZE [ALPHA] 014
[XEQ] [ALPHA] 
RT [ALPHA]              SEED?
.12569 [R/S]            NO. OF ROBOTS
3 [R/S]                 F.F. AT 7,8
[R/S]                   F.F. AT 7,1
[R/S]                   F.F. AT 3,6
[R/S]                   F.F. AT 3,3
[R/S]                   ROBOT AT 6,8
[R/S]                   ROBOT AT 0,6
[R/S]                   ROBOT AT 7,9
[R/S]                   ANDROID: 6,1
3 [R/S]                 STUMBLE
                        ROBOT AT 7,7
[R/S]                   ROBOT AT 1,5
[R/S]                   ANDROID: 7,0
4 [R/S]                 ROBOT AT 6,6
[R/S]                   ROBOT AT 2,4
[R/S ]                  ANDROID: 6,0
   .                        .
   .                        .
   .                        .	

The Program

LINE  KEYS
 01 <>LBL "RT"
 02  SF 27               Initialize
 03  "SEED?"
 04  PROMPT
 05  STO 00
 06 <>LBL E
 07  "NO. OF ROBOTS"
 08  PROMPT
 09  STO 03
 10  2
 11  *                   Calculate size
 12  1
 13  +
 14  6
 15  +
 16  "SET SIZE "
 17  FIX 0
 18  CF 29
 19  ARCL X
 20  SF 25
 21  1
 22  -
 23  STO IND X           See if reg. exists
 24  FC?C 25
 25  PROMPT
 26  RCL 03
 27  1 E3
 28  /
 29  ST+ 03
 30  6.005
 31  +
 32  STO 02
 33  RCL 03
 34  +
 35  .001
 36  +
 37  STO 01
 38  FRC
 39  6
 40  +
 41  STO 03
 42  5.004
 43  STO 04
 44  100
 45  XEQ 99
 46  10
 47  /
 48  STO 05
 49 <>LBL 00             Get positions
 50  RCL 04
 51  100
 52  XEQ 99
 53  10
 54  /
 55 <>LBL 11
 56  RCL IND Y
 57  X=Y?                Make sure no two are the same
 58  GTO 00
 59  RDN
 60  DSE Y
 61  GTO 11
 62  STO IND 03
 63  1
 64  ST+ 04
 65  ISG 03
 66  GTO 00
 67  FIX 1
 68  CF 28
 69  RCL 01
 70  "F. F. "
 71  ASTO 03
 72  XEQ 10              Output F.F's once
 73 <>LBL 98
 74  CF 28
 75  RCL 02
 76  "ROBOT "
 77  ASTO 03
 78  CF 05
 79  XEQ 10              Output robots
 80  "ANDROID: "
 81  ARCL 05
 82  AVIEW
 83  SF 28
 84  FS? 05
 85  GTO 97
 86  PSE
 87  "ANDROID SAFE"
 88  AVIEW
 89  TONE 9
 90  TONE 8              Safe tune
 91  TONE 9
 92  TONE 7
 93  TONE 9
 94  RTN
 95 <>LBL 10
 96  STO 04
 97 <>LBL 16
 98  RCL IND 04          Output loop
 99  X<0?
100  GTO 10
101  SF 05
102  CLA
103  ARCL 03
104  "|-AT "
105  ARCL X
106  AVIEW
107  STOP
108 <>LBL 10
109  ISG 04
110  GTO 16
111  RTN
112 <>LBL 97
113  CF 22
114  STOP                Input
115  FC? 22
116  GTO 98
117  GTO IND X
118 <>LBL 01
119  -1.1                Change digit into delta XY
120  GTO 10
121 <>LBL 02
122  -.1
123  GTO 10
124 <>LBL 03
125  .9
126  GTO 10
127 <>LBL 04
128  -1
129  GTO 10
130 <>LBL 05
131  0
132  GTO 10
133 <>LBL 06
134  1
135  GTO 10
136 <>LBL 07
137  -.9
138  GTO 10
139 <>LBL 08
140  .1
141  GTO 10
142 <>LBL 09
143  1.1
144 <>LBL 10             Update android position
145  ST+ 05
146  RCL 05
147  XEQ 96
148  FS? 05              Android blunder
149  GTO 95
150  RCL 02
151  STO 03
152 <>LBL 14
153  RCL 05              Move robots
154  INT
155  RCL IND 03          Recall robot
156  X<0?
157  GTO 10
158  INT
159  -
160  X!=0?
161  SIGN
162  RCL 05
163  FRC
164  RCL IND 03
165  FRC
166  -
167  X!=0?
168  SIGN
169  10
170  /
171  +
172  ST+ IND 03          Update robot
173 <>LBL 10
174  ISG 03
175  GTO 14
176  RCL 02
177  STO 03
178 <>LBL 15
179  -1
180  X<> IND 03
181  X<0?
182  GTO 10
183  XEQ 96
184  FC? 05
185  GTO 10
186  -1
187  "BUMP"
188  FS? 06              Robot blunder
189  "STUMBLE"
190  AVIEW
191  TONE 9
192  CLD
193 <>LBL 10
194  STO IND 03
195  ISG 03
196  GTO 15
197  RCL 05              Robot get android?
198  XEQ 96
199  FC? 05
200  GTO 98
201 <>LBL 95
202  "STOMP"             Android loses
203  FS? 06
204  "ZAP"
205  AVIEW
206  TONE 0
207  "TOO BAD"
208  AVIEW
209  RTN
210 <>LBL 96
211  SF 05               Android or robot blunder routine
212  SF 06
213  RCL 01
214  X<>Y
215 <>LBL 12
216  RCL IND Y
217  X=Y?
218  RTN
219  RDN
220  ISG Y
221  GTO 12
222  CF 06
223  RCL 02
224  X<>Y
225 <>LBL 13
226  RCL IND Y
227  X=Y?
228  RTN
229  RDN
230  ISG Y
231  GTO 13
232  CF 05
233  RTN
234 <>LBL 99
235  RCL 00              Random number generator
236  9821
237  *
238  .211327
239  +
240  FRC
241  STO 00
242  *
243  INT
244  RTN
245  .END.

Register Use

R00  Seed
R01  Used
R02  Used
R03  Used
R04  Used
R05  Used
R06  Android
R07  Robot1
...  ...
     Robotn
     FF1
     ...
     FFn+1

Flags

05  Used
06  Robot/FF

Go back to the HP-41 software library
Go back to the general software library
Go back to the main exhibit hall