Skip to content

nashitshayan/battleship

Repository files navigation

BATTLESHIP

👉Live Preview👈

Description

Battleship is a strategy type guessing game for two players. It is played on ruled grids on which each player's fleet of warships are marked. The locations of the fleets are concealed from the other player. Players alternate turns calling "shots" at the other player's ships, and the objective of the game is to destroy the opposing player's fleet.

Learnings

  1. Understanding Test Driven Development (TDD)
  2. Seperation of concerns
  3. Decoupling app logic from UI (the game can be played without any UI, on the console)
  4. Using Jest for testing
  5. Writing out my thought process and keeping a log of my progress helped declutter my mind and solidify my approach.

Technologies used

  1. JS
  2. Jest
  3. HTML
  4. CSS
  5. Webpack

Challenges I faced

  1. Working without any UI was a first for me.
  2. Understanding what to test and what to ignore.
  3. Relying on tests instead of usual console logs
  4. Placing ships on the boards.
  5. Getting the AI to randomly place its ships and randomly attack enemey board correctly.

Room for improvement

  1. A way for player to place their ships. Right now the player's ships are placed with pre-determined coordinates.
  2. A smarter AI. If it hits your ship, it should then attack adjacent cells.
  3. Mobile support. Right now the game can only be played on desktops/laptops.