Tic Tac Toe Retrospective


The Tic Tac Toe project was my first time making a game with HTML, CSS, and JavaScript. The trickiest part of this game was writing the computer AI. The recommended route was to use an algorithm called Minimax, but at the time I was not able to read and understand that algorithm, so I home brewed my own AI.

This project really stepped up the JavaScript complexity, but I really enjoyed and was excited after making my own video game.

Code Review

The HTML is pretty simple in this project just due to the simplicity of a tic tac toe board. I was still relying upon Bootstrap for laying out the board. I did use some responsive column sizes and my tic tac toe game is mobile-friendly.

The JavaScript is, frankly, a mess. Because I didn't understand Minimax, my AI is 450 lines of if else if blocks. At the time, it was the only approach I could think of. It doesn't make my tic tac toe AI unbeatable, but it is pretty decent. As much as it sounds like an excuse, I also thought, and still do, that an unbeatable AI makes for a pretty awful tic tac toe game. Despite that, the increase in complexity here from the Pomodoro and Calculator is huge.

Future Improvements

The JavaScript for this application should be completely rewritten from scratch. Right now, it's about 700 lines. I could probably do it now in half or less than that number. I haven't decided if this app will get rewritten in Angular.

  • Get rid of Bootstrap since this is so simple and use flexbox
  • Remove jQuery and use vanilla JavaScript
  • Rewrite AI logic using something more elegant than a bunch of if else ifs