Demo: https://jonslui.github.io/battleship/dist/index.html
A turn-based strategy game where players take turns firing shots into enemy waters. The first one to destroy all enemy ships wins.
When planning this project, my goal was to gain experience using Jest and Test Driven Development while keeping my player, gameboard, and ship factories as pure as possible. This was my first time using TDD on something larger than small practice problems, and it was a great feeling how everything came together cleanly at the end.
To keep the game competitive, I added 'intelligent' decision-making to the AI. If the AI player hits a tile, it will search the 4 adjacent tiles before beginning to randomly search the waters again.
- Practice using Jest (tests found in src/factories folder).
- Gain experience using TDD.
- Practice creating modular code and keeping functions pure.
- Click this link: https://jonslui.github.io/battleship/dist/index.html or download files and open index.html in a browser of your choice.
place.ships.and.launch.attack.mov
- Drag and drop your ships.
- Click a tile on the opponent's board to attack (red means hit, white means miss).
Sink.a.ship.mov
- Hit all tiles of an opponent's ship to destroy it.
End.game.and.start.again.mov
-
The first player to destroy all their opponent's ships wins
-
Click "New Game' to play again.
-
Enjoy!