Im Magazin „Microcomputing" wurde im Juli 1978 der folgende Artikel abgedruckt.
Das Strategiespiel Battleship - Schiffe versenken.
Battleship!
Harley Dyk
Mona Shores High School
1121 Seminole Rd.
Muskegon Ml 49441

The classic game of Battleship has been around for years. I can recall playing the pencil-and-paper version in the 1950s, and fancy peg versions are still available in stores.
The game is for 2 players; each hides five ships on his 10 x 10 grid (which his opponent cannot see). The grid columns are numbered from 1 to 10 and the rows lettered from A to J. The ships and their lengths are shown in Table 1. Ships may be placed vertically or horizontally; no diagonal placements are allowed.
ShipLength
Aircraft carrier5
Battleship4
Cruiser3
Submarine3
PT boat2
 
Table 1.
Lines   Function
2-45   Instructions, data and matrix setup statements.
60-140   You hide your ships.
142-146   Attack strategy.
150-240   Computer hides ships.
251-253   Won-lost check.
255-270   Your shot.
290   Routes action to search for Hit 1, 2, or 3, 4, and/or 5, if necessary.
300-308   Routine to check if ships were hit when sinking another ship.
310-390   Search for Hit 1 on a ship
400-502   Search for Hit 2 on ship.
510-590   Search for Hits 3, 4, and/or 5, if necessary.
600   Play again?
700-701   Subroutine to print out hidden ships if you lose.
800-898   Subroutine to check if there is room for certain ship's length at a certain location or orientation.
900-906   Subroutine to go left, right, up or down, after Hit 1 on ship.
950-954   Subroutine to continue searching for more of ship in direction of last hit for Hits 4 and 5, if necessary.
1000-1050   Grid printout subroutine.
 
Table 2.
The game is played by the players taking turns calling off coordinates of suspected enemy-ship positions. G-9, for example, would indicate the point in row G, column 9. A player must also give the name of the opposing ship hit in that event. The game continues until one of the players has destroyed all 17 points of his opponent's ships.
A computer program allowing 2 people to play Battleship against each other would be a good challenge, but to get the computer to play intelligently and competently seemed more challenging. Games like Star Trek and Hangman are excellent, and specify what the player must do in a certain number of steps, but do not actually pit the player against the computer (and its program). This is possible in games such as Ticktacktoe, Checkers, Chess and Battleship.
A program listing and some typical output follows. To conserve memory, REM statements were not used in the program, but Table 2 gives a summary statement of the functions of various sections of the program.
The program follows the traditional rules; the only difference is how the coordinates are called. To name C, 6, for example, I used 3, 6 simply numbering the rows rather than using letters. The program instructions are rather short due to memory limitations; but if you read this article and look at the sample output, you should have no trouble getting started.
The program is written in Mits Extended BASIC; however, only lines 260, 318, 452 and 600 would have to have their if-then-else instructions changed to conform to 8K BASIC. As usual, the program expanded to fill the available memory, and just resides and runs in the 6084 bytes I have available. The game was not designed to be played on a teletypewriter unless the player has an hour or two and surplus paper. At 9600 baud on a CRT, one can play game in five minutes (once accustomed to the program).
Although the computer "knows" where your ships are, at no time does it use this information to play more intelligently. My experience indicates that the computer's luck runs in streaks. When I perfected the version of the game shown here, the computer beat me the first three times. After that put-down, I became more serious and have become a better player; I now win three or four games out of five.
You will probably have to play at least ten games to get a good idea of your ability against the computer and its ability against you. You should win some easy ones, have some close victories and lose occasionally.
If you want to make the program easier (or harder), you must consider lines 312-320, as they are a key part of the attack strategy. If they are removed, the game will be much easier. They can also be revised to make the game slightly easier. To trim the ego of someone who wins regularly, change the 5 at the end of line 150 to a 4. This makes it impossible to win.
Another possible change is the .85 in line 200. Making this number smaller increases the probability that the computer will hide ships next to each other. This makes things trickier – especially if the player assumes that ships are never adjacent.
Since the computer plays somewhat intelligently and systematically, it may need to "think" longer as the game progresses before it picks a point. Occasional thinking delays of 10 or 15 seconds near the end of the game are normal, so don't be too impatient with your computer. The BASIC language does not yet have the long awaited HUNCH statement available (this statement will give the computer extrasensory perception and mind-reading ability when playing games). Happy sinking!

(A paper tape copy of the program is available from the author for $4.00.)

Opening instructions and grid display, followed by a sample placement of the aircraft carrier.
Das Originalprogramm war ohne Leerzeichen geschrieben, hier das Programm Listing mit Leerzeichen.
The final ship being hidden, followed by the opening shots of the game by the computer and player.)
Typical mid-game action. On the left grid, hits by the computer show up as Hs, misses as asterisks. As you discover the computer's ships on the right, the first letters of the ships will show.

Eingescanned von Werner Cirsovius
Januar 2014
© Microcomputing (kilobaud)