I think my Tic Tac Toe game has an unbeatable AI?

I think my Tic Tac Toe game has an unbeatable AI?
0

#1

The AI is based off of Wikipedia’s optimal strategy, and I think it’s unbeatable? At least, I haven’t been able to beat it yet. Feedback/comments/you telling me that you beat it is absolutely welcomed!

https://bethqiang.github.io/tic-tac-toe/


#2

Rage Quits :rage:

Its completely unbeatable!

maybe you should add an optional easier version for people like me?


#3

Seems unbeatable to me.

One thing to consider: I think the convention is that X always goes first, so if I select the O token, the computer should get the first move.


#4

corner, diagonal opposite corner, corner, win.


#5

Sorry, but I beat it easily :slight_smile:


#7

I somehow never knew this rule–but will definitely change my game to reflect that. Thanks! :slight_smile:


#8

@jenovs @zelite @P1xt - noted. Will go back into the code and see what I can do. :slight_smile: Thanks!


#9

Great implementation, I had issues with the AI so finally I started with a multiplayer version. I hope if you don’t mind if I will look into your code to check how you’ve resolved the AI :slight_smile:


#10

Not at all! I mostly brute-forced a strategy instead of using an actual algorithm, although I do hope to implement the Minimax algorithm at some point. :slight_smile:


#11

I think that tic tac toe is a game where two reasonably skilled players should always come to a draw. It is possible to never lose at tic tac toe. As such, it is a great place to design your first AI, because you can enjoy real undeniable success.


#12

Oh wow, I used the strategy from Wikipedia on mine, too.
Great job on your game!
Unfortunately, though, both of our AIs are beatable (though yours is at this point much harder to beat than mine). I wonder if it is even possible to use Wiki’s strategy to create an unbeatable AI.


#13

I believe it is possible - I just forgot to include one of the points in Wikipedia’s strategy. :slight_smile: That’s the only flaw that people have exposed about it so far, so I’m inclined to think that if I patched that up, it would be unbeatable. I think. :grin:


#14

I think you’re right.
I’ve worked on mine some more and it seems unbeatable: Codepen


#15

These examples of the tic-tac-toe game are all fantastic great job! I mindlessly played the OP’s version for like 15 min without realizing. :blush: There is still the corner’s issue, but the game is exellent. It is responsive and has a very nice design. I can’t wait untill i am able to try this challenge myself!


#16

I won your game… you are not having all the options yet…


#17

not even difficult lmao


#18

I just beat yours on the 3rd try.

Started in top left corner. AI played center.
Rather than blocking, I played bottom center. The computer played top right corner.
I blocked with bottom left corner.
Computer blocked with left center.
And I win by playing lower right corner.

Playing pure defense, I always end in a tie with yours.


#19

Was able to beat it following steps outlined in other comments.

But overall, this is super well done. Very clean design and interface. The only thing I’d change would be adding a slight delay before the computer’s move is displayed. (I find the immediacy of the computer play a bit disconcerting. I also noticed it actually plays a move in the split second between my winning move and displaying the “You win” message.)


#20

I believe that I made a unbeatable TicTacToe ia using the Minimax algorithm. It took a great time to I undertand him but i believe that i got it. That only problem now I think that is that in moves of the AI in the first match and the second match take a long time.


#21

i can beat your game , when i start first at 8th cell your game fill the 5th cell i fill the 1st cell your game fill the 3 rd cell i fill 7 th cell your game fill the 4th cell so i fill 9th cell , 789 i win , please check mine and give your suggestion and rate me on 10