Battleship game against AI in python
MIT License
This is a simple python program that lets the user play against an AI oponent.
To install Battleship, you will need to have python installed. Download python here.
This program will not run on python 3. So download the Python 2.7 package. Once you have downloaded the Python 2.7 executable, run it and go through the installer. Now with python installed, we can download and run the game! To download the game just hit the green button labled Clone or download and then hit the Zip folder button.
Once the zipped folder is downloaded, You can extract the files. This is different for every operating system, for windows I recomemnd 7-zip. After unziping the files, just double click on the file BattleShip.py.
Once you've started the python script, the game should run immediately. If you see a window pop up and then close, you're probably using python 3. Make sure to run this game using python 2.7.x. This game is exactly like the board game battleship. On the left side is your view of your AI opponent's board. On the right side is your board and battleships. The battleships are represented by the brackets and plus symbols. Each ship can be vertical or horrizontal. Each player gets five ships. One size five ship, one size four ship, two size three ships, and one size two ships. The ships are arranaged on a ten by ten grid. The top left corner being row zero column zero and the bottom right corner being row nine column nine.
The object of the game is simple, sink all of the enemy ships before they can sink all of yours. Each player turn, you get to fire one shot based on the coordinate you input. Then the AI will take their turn. When an AI hits you, they will try to hit around that spot to try and find the rest of your ship. When they do, the game will print out the version of your board that they can see. To understand the board, we'll explain each symbol. The symbol X represents a spot that has already been shot at but was just a miss. The symbol O represents a spot that has not been hit by anything. Lastly the * symbol represents part of a ship that has been hit. Once either you, or the AI has one the game will end. To play again simply restart the program.
This project is licensed under the MIT license.