Pegged! for the HP-67/97

Back to main page | Email me at: Gene!


The program presented below will allow you to play a game called "Pegged" on the HP-67/97. It was written by Craig Pearce (a fellow CHiP chapter member!) and appeared in the V4N6P50 issue of the PPC Journal (June 1977). Thanks to Craig in Chicago!

Picture a playing board that looks like this: (Note: only the numbers are shown in the display. The other symbols are supposed to represent pegs. (I never was much of an artist!))

  ___  ___  ___       ___  ___  ___ 
 |   ||   ||   |     |   ||   ||   |
 |   ||   ||   |     |   ||   ||   |
 |   ||   ||   |     |   ||   ||   |
 |___||___||___|     |___||___||___|
   |    |    |         |    |    |
0. 1    1    1    0    2    2    2
This board shows what a 3 peg game would look like. You are to try to move the 1 pegs to the right side of the board/display, and the 2 pegs to the left side of the board/display. You may do this by moving 1 pegs either 1 step to the right or two steps to the right, and by trying to move 2 pegs 1 step to the left or two steps to the left. For example, the first move I might try to make would be to move a 1 peg 1 space to the right. If you'll notice, I don't have to specify which peg should be moved, since there is only one 1 peg that CAN go 1 space to the right. The display would then look like this:
0. 1    1    0    1    2    2    2
I then have a choice to move another 1 peg either 1 or two pegs to the right, but notice that if I do, the board would be in a position where I could not move any 1 or 2 pegs at all! That would mean that I lost! So my next move would be to move a 2 peg two spaces to the left. The board would look like this:
0. 1    1    2    1    0    2    2
And so on. It's pretty trivial with 1 or 2 pegs on the board, but tough when you have 3 or 4 pegs on the board. Makes you really have to plan ahead!
Initial Instructions:
1) Load the program and switch to RUN mode.
2) Select the number of pegs in the game and input this number (1 through 4). Press E. The playing field will be displayed.
3) To move a 1 peg one space right, press A.
4) To move a 1 peg two spaces right, press B.
5) To move a 2 peg one space left, press C.
6) To move a 2 peg two spaces left, press D.
7) You may recall the number of turns you've taken at any time by pressing f b.
8) You may turn printing on and off (on the HP-97) by pressing f a. (A 1 means that printing is turned on, a 0 means that it is turned off). 9) Continue moving pegs with steps 3-6 above until you win or can't move. If you win, the number of turns you took will be displayed.
Program Listing: Email if you have any questions.
Line      Instruction
01         LBL E
02         CL REG
03         INT
04         X = 0
05         GTO 0
06         ABS
07         4
08         X <> Y
09         X > Y
10         GTO 0
11         STO D
12         STO B
13         2
14         *
15         1
16         +
17         ST I
18         STO E
19         2
20         LBL 1
21         STO (i)
22         DSZ
23         GTO 1
24         RCL E
25         RCL D
26         -
27         ST I
28         0
29         STO (i)
30         DSZ
31         1
32         LBL 2
33         STO (i)
34         DSZ
35         GTO 2
36         RCL E
37         ST I
38         CLX
39         LBL 3
40         1
41         0
42         /
43         RCL (i)
44         +
45         DSZ
46         GTO 3
47         1
48         0
49         /
50         RCL E
51         ST I
52         DSP (i)
53         RDN
54         F? 0
55         PRTX (-x-)
56         RTN
57         LBL B
58         SF 1
59         LBL C
60         1
61         GTO d
62         LBL A
63         SF 1
64         LBL D
65         2
66         LBL d
67         STO D
68         1
69         RCL A
70         +
71         STO A
72         RCL E
73         ST I
74         LBL 4
75         RCL (i)
76         X = 0
77         GTO 5
78         DSZ
79         GTO 4
80         LBL 5
81         RC I
82         STO C
83         RCL D
84         F? 1
85         CHS
86         +
87         ST I
88         RCL (i)
89         2
90         X <> Y
91         F? 1
92         1
93         X NE Y
94         GTO 0
95         0
96         STO (i)
97         CLX
98         RCL C
99         ST I
100        RDN
101        STO (i)
102        CF 1
103        RCL B
104        ST I
105        LBL 6
106        2
107        RCL (i)
108        X NE Y
109        GTO e
110        DSZ
111        GTO 6
112        RCL B
113        1
114        +
115        ST I
116        RCL (i)
117        X NE 0
118        GTO e
119        SF 2
120        LBL e
121        RCL E
122        ST I
123        CLX
124        GSB 3
125        F? 2
126        F? 2
127        R/S
128        PAUSE
129        RCL A
130        DSP 0
131        F? 0
132        PRTX (-x-)
133        F? 0
134        SPC
135        RTN
136        LBL a
137        F? 0
138        GTO 7
139        SF 0
140        1
141        R/S
142        LBL 7
143        CF 0
144        0
145        R/S
146        LBL b
147        RCL A
148        RTN
149        LBL 0
150        CF 1
151        CLX
152        /
153        R/S

That's it!
Visitors since 8/6/97