Battleship II for the HP-25/25C

Back to main page | Email me at: Gene!


The program presented below will play the game of Battleship on the HP- 25. It was written by John Ball and appeared in the Sample issue A of PPC Journal. Thanks to John wherever he is today!

An enemy battleship starts somewhere within a 100 x 100 grid, with 0 < x < 100, and 0 < y < 100. After each shot, specified by an x, y coordinate, the distance from your shot to the battleship is displayed for one pause. If that distance is less than 1, you score a hit and win the game. the display will show ShELL.hOLE upside down. If the distance is between 1 and 5, you score a minor hit. Five minor hits will also win. The display shows BILGE.hOLE upside down.

After each shot, the battleship moves, but unless you score a minor hit, by less than 1 unit. After a minor hit, the battleship gets scared and runs away. The damage from several minor hits slows him down only a little. Note: Both the battleship and your shots can move outside the original grid.

Instructions:
0) Key the program in. Switch to RUN mode.
1) Store these constants: 3704.77345 STO 6, 3704.39718 STO 5, FIX 5
2) Press 0 STO 0, key a random number greater than 10 but less than 100 and press f PRGM, R/S.
3) Shoot by entering the x, y coordinate as X ENTER Y, R/S.
4) The display will pause showing the distance of your shot from the battleship, then either of the two messages, if appropriate or the number of total minor hits.
5) Repeat step 3 until you sink the ship.


Program Listing: Email if you have any questions.
Line      Instruction  Keycode
01         f LN         14 07
02         g FRAC       15 01
03         EEX          33
04         2            02
05         *            61
06         STO 1        23 01
07         g FRAC       15 01
08         EEX          33
09         2            02
10         *            61
11         STO 2        23 02
12         RCL 0        24 00
13         R/S          74
14         RCL 2        24 02
15         -            41
16         X <> Y       21
17         RCL 1        24 01
18         -            41
19         g ->P        15 09
20         f PAUSE      14 74
21         1            01
22         f X > = Y    14 51
23         GTO 45       13 45
24         -            41
25         4            04
26         f X > = Y    14 51
27         GTO 35       13 35
28         X <> Y       21
29         /            71
30         f ->R        14 09
31         STO - 1      23 41 01
32         X <> Y       21
33         STO - 2      23 41 01
34         GTO 12       13 12
35         1            01
36         STO + 0      23 51 00
37         +            51
38         RCL 0        24 00
39         f X > = Y    14 51
40         GTO 43       13 43
41         -            41
42         GTO 28       13 28
43         RCL 5        24 05
44         GTO 00       13 00
45         RCL 6        24 06
46         GTO 00       13 00

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