Tic Tac Toe Bot

Originally posted on August 3, 2024

My first project this summer was to make a Tic Tac Toe Bot. I started by writing out an “assignment” for myself.

Play the game

Summative Assessment

Situation: Who, what, where, when, why

  • In collaboration with my mentor, I came up with a plan to complete 3 projects this summer that would help me learn new skills and explore career paths.
  • The first project: Use raw HTML, CSS, and JS to build a basic Tic Tac Toe local co-op game. After that, build an AI bot to play against.
  • Complete in 3 weeks
  • My goal was to practice completing a MVP and learn about what approaches help avoid overscoping a project. In addition to learning how to a simple AI bot.

Task: Your responsibility and challenges

  • I was responsible for writing my “assignment” and building the project
  • I ran into challenges when my minimax algorithm was not working as expected

Action: What you did and why

  • As my second checkpoint approached, I realized I had two options: Ask someone for help or start over following a different tutorial with more explicit instructions.
  • I reached out to some friends for fresh eyes and worked on other areas of the project.
  • I refered to other tutorials to see what they did differently.

Results: Outcome, what you have learned, how you apply it

  • In the end, using other tutorials helped me debug my code
  • I learned how to apply recursive algorithms to practical uses
  • I have a better understanding of how to focus on the bare minimum features in order to complete a project quickly
  • I learned that it’s very beneficial to approach project planning from a “teacher’s” perspective

Three Areas: What did you enjoy? What were you best at? What do you want to improve on?

  • I enjoyed coding the game mechanics and debugging the algorithm
  • I was the best at quickly putting together the basic site with local co-op game play.
  • I want to get better at coding the game mechanics efficiently. I completely refactored the game functionality after the first try because it was convoluted. And I still think my completed pass could use an additional refactor.

Takeaways: If you could do this again, what would you do differently?

  • I would write messier code from the start and clean it up later, as opposed to try to write somewhat “clean” code from the beginning and as a result have a lot of extraneous pieces. For example, I created a Game class to store the board state and current player but I could have gotten away with just an array and variable, since the game class only really needed to be instantiated once.

References

Tic Tac Toe: Understanding the Minimax Algorithm

Building a Tic-Tac-Toe AI with Javascript

Tic Tac Toe AI with Minimax Algorithm


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *