Post Reply 
(71B) Battelship Game for HP-71B
12-23-2013, 11:48 AM (This post was last modified: 06-15-2017 01:39 PM by Gene.)
Post: #1
(71B) Battelship Game for HP-71B
Simple game of battleship where you and the computer have 10 ships located on a grid defined by the corners (1,1) and (100,100). The calculator will then prompt you for (X,Y) coordinates that should be in the range of (1,1) to (100,100). Each of you and the machine drop bombs at various locations in the game's grid. If the bomb is close enough to a ship, then the ship is hit. The first player that looses all 10 ships loses the game.

The program displays the coordinates of your bombing and it they are successful. Likewise, it displays where the machine strikes and the success of that strike.

The listing below sets the game to play in automatic mode (i.e. the calculator plays both as itself and as you). To play in manual mode, set line 440 as DATA 0. The calculator will then prompt you for (X,Y) coordinates that should be in the range of (1,1) to (100,100). Each of you and the machine drop bombs at various locations in the game's grid. If the bomb is close enough to a ship, then the ship is hit. The first player that looses all 10 ships loses the game.

The program displays the coordinates of your bombing and it they are successful. Likewise, it displays where the machine strikes and the success of that strike.

Code:
10 REM SUB HUNT
20 DESTROY ALL
25 DEF FNR(M)=INT(1+M*RND)
30 DIM X(10),Y(10)
40 N=5@ RANDOMIZE
45 REM NUMBER OF SHIPS
50 P=5@ C=5 
55 REM AUTOMATIC MODE FLAG (0=MANUAL NOT 0=AUTOMATIC)
60 READ F 
70 FOR I = 1 TO N@ READ X(I),Y(I)@ NEXT I
80 FOR I = N+1 TO 2*N
90 X(I) = FNR(100)
100 Y(I) = FNR(100)
110 NEXT I
120 DISP "START"@ WAIT 2
130 DISP "SCORE ";P;":";C @WAIT 2
140 A = FNR(100)@ A$=STR$(A)
150 B = FNR(100)@ B$=STR$(B)
160 IF F<>0 THEN GOTO 190
170 INPUT "ENTER X? ";A$,A$@ A=VAL(A$)
180 INPUT "ENTER Y? ";B$,B$@ B=VAL(B$)
190 DISP "YOU BOMBED";A;",";B@ WAIT 2
200 FOR I = N+1 TO 2*N
210 D=SQR((X(I)-A)^2+(Y(I)-B)^2)
220 IF D>INT(5+6*F*RND) THEN 290
230 DISP "CALC HIT"@ WAIT 1
240 X(I)=-1000@ Y(I)=-1000
250 C=C-1
260 IF C>0 THEN 290
270 DISP "YOU WIN!"
280 END
290 NEXT I
300 A = FNR(100)
310 B = FNR(100)
320 DISP "CALC BOMBED";A;",";B@ WAIT 2
330 FOR I = 1 TO N
340 D=SQR((X(I)-A)^2+(Y(I)-B)^2)
350 IF D>10 THEN 420
360 DISP "YOU WERE HIT"@ WAIT 1
370 X(I)=-1000@Y(I)=-1000
380 P=P-1
390 IF P>0 THEN 420
400 DISP "CALC WINS"
410 END
420 NEXT I
430 GOTO 130
435 REM DATA 1 SETS AUTOMATIC MODE
440 DATA 1
450 DATA 15,15,30,30,45,45,60,60,75,75
Find all posts by this user
Quote this message in a reply
03-12-2017, 03:16 PM
Post: #2
RE: Battelship Game for HP-71B
A friend of mine and were talking about the HP-71B and he mentioned it was a computer with 32K. That is about 16K short of my favorite computer, the Atari 800. So I said "Someone probably made a game on it even though the display is only one line of characters" And I was delighted to find this game to show what people will do. Big Grin

Naturally would love to find other games, but might have to pull out my HP-71B (my friend claims he gave me one and I might still have it) and try this program out.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)