My Tic-Tac-Toe game - Should be unbeatable

Please check my Tic-Tac-Toe game.

Try to win :slight_smile:

AI is implemented without using MiniMax, so it is possible there are some edge cases I didn’t think of.

Any feedback appreciated.


I confirm, can only do tie. :slight_smile:

1 Like

Nice job! I couldn’t beat it either.

So, looking at your code on Github, yours is more of a hardcoded strategy?

// if AI moves first, take corner

// if AI moves second, take center, if center taken, take corner…

Did you choose this because it’s a known ‘optimum’ unbeatable strategy that’s documented somewhere, or did you work out this ‘unbeatable’?

Very curious as to why you went in this direction. About to start the project myself and trying to decide if I want to learn minimax.

Unbeatable without minimax as far as I can see. This is very cool.

I got this strategy from Wikipedia.

I tried minimax, but I just couldn’t translate the algorithm to JavaScript so I did a little research and found the mentioned Wikipedia article and went with hardcoding the strategy.

Got it. Nice work.

I found a good article explaining minimax - I’m going to try and implement it. Then I’ll go your way if I find it impossible:

1 Like

I win the second time, before my turn, sorry:

1 Like

Thank you @mikeale03 and @xavierartot for your feedback.

I’m currently working on my fCC Back-End projects, but someday I’ll come back to update the frontend projects and will fix the bugs you pointed out :wink: