The Museum of HP Calculators

# Scatter 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

N atoms are randomly placed in a black box with dimensions l0x10. No atom can be on the edge of the box. By firing particles into the box from the edges, and noting their exit locations, you attempt to find the atom positions. For a single atom, the scatters and reflections are as shown in Figure 1. Multiple atom scatters are simple extensions of this diagram: See, for examples, Figures 2 and 3. Note in particular, the back reflections of Figure 3 which arise from two combined scatters. More complex scattering and reflection are shown in Figure 4 where atom 4 causes scatter A, atom 2 causes B, 1 causes C, 4 (again) causes D, 3 causes E, and atom 1 reflects the particle back along the convoluted path. The numbering of the box grid is given in Figure 5. The 5th position on the base has coordinates 5.0, the 7th on the right is 9.7, and so on.

You select the value of N, and the machine places the N atoms randomly. You then fire particles from the edge: The machine tracks them and displays the output edge locations. At any time you can get the machine to confirm or reject any suspected atom location. If the guess is wrong, you are "penalized" by having the number of used particles increased by 5. The object of the game is not only to find the atoms, but to do so with the minimum number of probes.

NOTE: Although 9 atoms may be placed, a "good" game is 4 or 5.

Diagrams

Note: Requires 1 Memory Module on HP-41C

## Instructions

 Step Instructions Input Data/Units Keys Output Data/Units 1 Enter program 2 Initialize [XEQ] SCATTER SEED? 3 Key in number between 0 and 1 seed [R/S] NO. OF ATOMS? 4 Key in number of atoms to be placed. N [R/S] READY 5 Key in an entrance point. x.y [R/S] (x).(y) 6 To guess a position key one in. x.y [A] YES (or) NO ( ) PROBES Continue with steps 5 and 6 as desired. 7 To start a new game go to step 4. [E] NO. OF ATOMS? 8 If at any time you give up you can find all positions. [C] (x).(y) . . .

## Example

Set up and find 4 atoms

```   Keystrokes:          Display:
[XEQ] [ALPHA]
SIZE [ALPHA] 022
[XEQ] [ALPHA]
SCATTER [ALPHA]         SEED?
.191062 [R/S]           NO. OF ATOMS?
2.0 [R/S]               0,2
4.0 [R/S]               9,2
3.3 [A]                 YES
2 PROBES
6.9 [R/S]               6,9
6.8 [A]                 NO
8 PROBES
0.8 [R/S]               9,8
.                        .
.                        .

```

## The Program

```LINE  KEYS
01 LBL "SCATTER"     Initialize
02  SF 27
03  CF 29
04  SF 28
05  FIX 0
06  "SEED?"
07  PROMPT
08  STO 00
09 LBL E
10  0                  Get number of atoms
11  STO 11
12  "NO. OF ATOMS?"
13  PROMPT
14  STO 10
15  1 E3
16  /
17  1
18  +
19  STO 12
20 LBL 00
21  XEQ 10             Place atoms
22  XEQ 10
23  10
24  /
25  +
26  RCL 12
27  INT
28  X<>Y
29  STO 09
30 LBL 01
31  RCL IND Y          Test to see if already filled
32  X=Y?
33  GTO 00
34  RDN
35 LBL 09
36  DSE Y
37  GTO 01
38  STO IND 12
39  ISG 12
40  GTO 00
42  AVIEW
43  GTO 20
44 LBL 10
45  RCL 00             Get a coordinate
46  9821
47  *
48  .211327
49  +
50  FRC
51  STO 00
52  8
53  *
54  1
55  +
56  INT
57  RTN
58 LBL 20
59  STOP               Get an entry point
60  INT
61  STO 12
62  STO 15
63  CF 00
64  X=0?
65  SF 00
66  9
67  X=Y?
68  SF 00
69  CF 01
70  X=Y?
71  SF 01              Select which side
72  LASTX
73  FRC
74  10
75  *
76  STO 13
77  STO 14
78  X=Y?
79  SF 01
80  1
81  ST+ 11
82 LBL 02
83  RCL 10
84  STO 21
85  10
86  STO 17
87 LBL 05
88  RCL IND 21         Get an atom
89  INT
90  LASTX
91  FRC
92  10
93  *                  Decompose into X and Y
94  RCL 13
95  -                  Get X,Y distances of probe
96  X<>Y               position from atom
97  RCL 12
98  -
99  FS? 00
100  X<>Y
101  STO 20
102  ABS
103  1
104  -                  Test X distance
105  X>0?
106  GTO 09
107  RDN                No effect on probe
108  STO 16
109  FS? 01             Test Y distance
110  CHS
111  X<0?
112  GTO 09             No effect
113  RCL 17
114  X<>Y               Atom hidden behind another?
115  X>Y?
116  GTO 09
117  SF 03
118  X!=Y?
119  CF 03
120  STO 17             Flag 3 on for reflection
121  RCL 20
122  STO 18
123  RCL 16
124  STO 19
125  SF 02
126 LBL 09
127  DSE 21             All atoms scanned?
128  GTO 05
129  FS?C 02
130  GTO 09             Perturbation?
131  0
132  ENTER^
133  9
134  FS? 01
135  X<>Y
136  RCL 12
137  RCL 13             Get exit coordinates
138  FS? 00
139  X<>Y
140  RDN
141  FS? 00
142  X<>Y
143  STO 15
144  RDN
145  STO 14
146 LBL 03            Display coordinates
147  CLA
148  ARCL 15
149  ","
150  ARCL 14
151  AVIEW
152  GTO 20
153 LBL 09            Perturbation
154  FS?C 03
155  GTO 03
156  RCL 12             Deflection
157  RCL 13
158  FS? 00
159  X<>Y
160  RCL 19
161  1
162  FS? 01
163  CHS
164  -
165  +
166  FS? 00
167  X<>Y
168  STO 13
169  RDN
170  STO 12
171  FS? 00
172  SF 02
173  SF 00
174  FS?C 02
175  CF 00
176  CF 01
177  RCL 18
178  X=0?
179  GTO 03
180  X>0?
181  SF 01
182  GTO 02
183 LBL A
184  RCL 10             Verify guess
185  X<>Y
186 LBL 04
187  RCL IND Y
188  "YES"
189  X=Y?
190  GTO 09
191  RDN
192  DSE Y
193  GTO 04
194  5
195  ST+ 11
196  "NO"
197 LBL 09
198  AVIEW
199  PSE
200  CLA
201  ARCL 11
202  " PROBES"
203  AVIEW
204  GTO 20
205 LBL C
206  RCL 10             Find and display all positions
207  FIX 1
208  CF 28
209 LBL 06
210  CLA
211  ARCL IND X
212  AVIEW
213  PSE
214  DSE X
215  GTO 06
216  SF 28
217  FIX 0
218  GTO 20
219  .END.
```

## Register Use

```R00  Seed
R01  Atom Location
R02  Atom Location
R03  Atom Location
R04  Atom Location
R05  Atom Location
R06  Atom Location
R07  Atom Location
R08  Atom Location
R09  Atom Location
R10  n
R11  Probe count
R12  particle x
R13  particle y
R14  x
R15  y
R16  Used
R17  Used
R18  Used
R19  Used
R20  Used
R21  Used
```

## Flags

```00  Top or bottom / Left or right
01  Top or right / Bottom or left
02  Used
03  Used
```