Note: This program requires two computers hooked together with a null modem cable. Also the program needs to know the com number of the two serial ports the null modem cable is connected.
In this game of battleship, the two players have each have their own computer, hooked together by a null-modem cable. They take turns firing their cannons at blank squares on their radar grid. When one player hits a square that is occupied by the other player, the damage is shown on both player?s screens. The first section decides which player/computer will go first. It does this by each computer sending a random number over the connection cable. The computer with the higher number goes first. The next section sets up the grids and menu. After the ships are placed, the computer that goes first branches the section that asks the player where to fire. It then waits for the opponent to fire. The two players keep firing until one has sunk all his opponent?s ships. The main problem was creating a program that would work on both computers, no matter which one went first. The comparing a random number generated by each machine solved that problem. Each computer keeps track of its own hits and misses, and location of its ships. The attacker sends the coordinates that he is attacking, and the receiving computer sends what he has at that location.