(85) Battleship game for HP-85
|
05-29-2014, 02:21 PM
(This post was last modified: 06-15-2017 01:39 PM by Gene.)
Post: #1
|
|||
|
|||
(85) Battleship game for HP-85
The following program is a battleship game for the HP-85. You can easily modify it to work with the HP-71B (by adding @ PAUSE after each DISP statement).
Code: 10 REM BATTLESHIP Notes User input (X,Y) can be: 1) Numbers between 1 and 1000. 2) The values (0,0) makes the computer select random coordinates. 3) The values (-1,<any value>) ends the program. 4) The values (1001 or higher,<any number>) displays the coordinates of the PC's ship and bombs the ship at the first coordinates. The X() and Y() matrix coordinates for player and PC are managed such that, the coordinate of a ship that is hit, is swapped with the last "valid" set of coordinates. The index of the last valid set of coordinates is N(K) and is decremented when a ship is hit. The program has set in line 360 a 5% chance that the PC can cheat and bomb the coordinates of the player's first ship. By changing the value in the expression RND>0.05 you can alter the probability for the PC to cheat. Enjoy! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)