Battleship
Background
This browser game was created while I was learning Javascript in the context of web programming. I wanted to create something simple enough that I could reasonably make it, yet complex enough to provide a challenge.

The game is based on “항공모함”[1], which is basically the Korean spinoff of Battleship. In this version, you get multiple shots per round based on the number of ships you have left (and more powerful ships give you more shots).
Screenshots
Starting the gamePlaying the gameWinning the game
Making the Game
Looking back, the game-making was made unnecessarily arduous by the fact that I didn't know many site-building tools yet (React, Express, etc). The entire website is made entirely through raw Javascript and DOM API calls. To be clear, using the DOM API directly isn't bad by any means. However, compared to something like React, which handles all interactions with the DOM for you, it is a bit messier to deal with.

This was also created at a time when I was fairly new to programming in general. At the time, I had been seriously programming for only a couple of months. Naturally, I had no knowledge of proper programming practices. This meant that my code had no modularity, no tests, and didn't use any design patterns[2]. And of these issues, the biggest was how tightly coupled my code was. Every time I changed anything in the code, I had to simultaneously make updates in several other places. This made debugging and updating the code a nightmare. Plus, since I didn't have any unit tests, bugs popped up frequently, making the problem even worse.

Eventually, I did get the game made. It's not perfect by any means[3]. But considering that I was a complete novice, I don't think it's that bad, either.

You can try out the game here:
https://shan2024.github.io/battleship/

  1. For more information, you can read about it here (if you can understand Korean): 항공모함
  2. There were many anti-patterns, however. The DOM.js file basically does everything related to DOM manipulation, making it a clear example of a god class. Not great.
  3. The most glaring issue is how terrible the AI is. I didn't bother with using any sophisticated algorithm, so as of now the AI is fairly easy to beat. Recently, however, I read a very interesting blog post about the optimal battleship algorithm. One of these days, I might come back to this project and implement it.