Battleships

One of my favourite childhood games, brought to life. Can you beat the computer?

Game in progress

I really wanted to bring one of my favourite childhood games to life on the screen after building Minesweeper. It was a big challenge considering how to generate a grid and automatically place the boats onto the grid, and then write a script to allow the human to play the computer. It was even more of a challenge writing a programme that sometimes wins – which it sometimes does!

My goal is to carry on working on this and try to get the computer to win almost half of the time…

  • July 2019 – First published in React 15 in July 2019
  • November 2022 – Completely refactored and republished in React 18
  • October 2023 – Significantly improved computer’s strategy and logic. The computer is much better at efficiently bombing ships when it finds them, and more efficient searching techniques. Wins more often.

Screenshots

Game setupSmaller boardOn mobile