Let's discuss your "Tic Tac Toe Game"

finally found time to complete it. the design is pretty basic, but if i didn’t make any mistakes it shouldn’t be possible to beat it and if you let it go first it has a couple of nasty surprises (i remembered tic tac toe meta and it’s very limited what you can do if you go second if you don’t want to lose) https://codepen.io/ead/full/OzKKxy

p.s. i didn’t do that vs another player part since user stories don’t demand it and it’s not any interesting to make it, i dunno why it’s included in the example app

1 Like

I have a very simple web design, most of my time was spent on implementing minimax algorithm (it recursively finds the move that maximises the computer odds of winning). Best suitable for hard mode except I didn’t make create easy and hard mode. When I’m done with front end I might go back and improve it.

Link - https://codepen.io/jenlky/full/eVeaKm/

Hi @jenlky! Thanks for sharing. I didn’t have a look at your script, but I noticed that:

  • since the 1st move by the human player takes a few seconds to show on the grid, the user can easily click several times (thinking it’s not working…)
  • the first move is always by the human player, not the computer (not sure if this is the way you wanted it)

Other than that it works pretty nicely :slight_smile:

Hi @ead: it’s minimalist and fast…! I like it!

Really nice @afaisalsahar. How did you define the several levels of difficulty when playing against the machine? It’s cool.

Thanks for replying. It take a few seconds because the computer recursively checks which move will lead to the best outcome. The minimax algorithm runs the game and take turns to be the AI and user, while testing all possible moves available. Therefore it lags a little.

One of my future improvements include creating a easy mode with hard-coded AI moves, that makes it easier for human player to win. This algorithm is more suitable for hard mode, as it’s almost impossible to win against unless I were to tweak it.

Once again, thanks for your feedback! Cheers

1 Like

Hi everyone - I definitely got a lot of inspiration from this thread. Now don’t hesitate to shoot if my implementation isn’t up to par.
https://user883311.github.io/tic-tac-toe/

Thanks in advance for any feedback/bug report :slight_smile:

I think this is the best result I’ve gotten so far with a FCC project and took the longest for sure. I’m pretty sure it’s unbeatable. My first vanilla JS project. Tic Tac Toe…can you beat it?

If click on a square I’ve already chosen it counts as a move.

1 Like

nice spot. I’ll have to fix that. Thanks!

Project Link - http://codepen.io/ivanlim/full/JLPyPq/

Note that I’m closing this thread. It’s much easier to get feedback if you create your own individual post requesting feedback for your own specific project.