Bi-Weekly Learning Update (25!)

Another couple of weeks, another chunk of freeCodeCamp completed! This past week I finished my Noughts & Crosses (Tic Tac Toe) project.

Check out my version of Noughts and Crosses here!

The game itself is pretty simple- you can choose to either be noughts or crosses, and crosses go first. The goal is to get three symbols in a row. A lot of people who have made this game (particularly in javascript) have used the minimax algorithm.  I decided against using it- I didn’t want to make the game totally unbeatable or rely completely on someone else’s work to make the game function.

I fully admit that the code is fairly basic, but I’m hoping that as I work on a couple more projects I can figure out a way to streamline it. Currently, the computer makes mostly random moves, unless the player has made two marks in a row, then it’ll block. You can beat the computer by ‘forking’- that is, having two possible ways to win.

I tried out jQuery UI for the first time in this project. I used it to make the dialog boxes where the player chooses what to play as (noughts or crosses) and the game outcome (player/computer win, or draw) jQuery UI is something I want to use more, so I’ll probably use it in my next project as well.

As it’s written now, the check for two out of three (for the computer to block) checks for combinations of two marks in a row or column- I had to manually enter the possible combinations and which move the computer should make to block it. I had a couple ideas on how to combine it with the check to see if either player had won, but it was becoming unnecessarily complicated, so I decided to stick with my solution until I’d had more time to think it over.

Onwards and upwards, right?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s