Sea Battle - a game of pure luck

Just BASIC Games
Posts: 63
Joined: Sat Oct 29, 2005 9:03 pm

Sea Battle - a game of pure luck

Post by uncleBen »

This game is normally played by two players using pencil and grid paper.
Each player places 10 "ships" in a 10*10 grid.
The ships are of following sizes: 1*4 squares, 2*3 squares, 3*2 squares and 4*1 square.
The rule for ship placement is that no two ships may be in adjacent cells (also diagonally).
Then, without seeing the other player's ships, they start calling coordinates to each other and the other player will reply whether this guess was a miss, a hit, or the whole ship is sinking.
The aim of the game is to guess the location ("sink") of all oponent's ships before the oponent does the same to you.

In this program one human player plays against the computer.
All the ships are placed randomly at the beginning of a new game. (I may modify this part, using arrays to cut the code shorter and may-be include manual placement for player.)
The player will "fire" at the left section, the computer at the right section where the player's boats are visible.
At the beginning of the game, the computer's boats are invisible (but still there).
Shooting is done by clicking on the desired cell.
"o" represents a miss, "x" represents a hit. When the computer's whole ship is sunk, it will become visible. (Player's ships will disappear as the computer manages to sink them.)

As this is a game of pure luck, player has a ~51% chance to win (I guess).

As this game uses sprites, make sure all the files are in the same folder to run the program.
You do not have the required permissions to view the files attached to this post.