Let's discuss your "Tic Tac Toe Game"

Project Link

Couldn’t implement the MiniMax :confounded:, so I went with algorithm from Wikipedia.

Project Link - https://codepen.io/bsandusky/full/vKxJvV/

@jenovs : It says “it’s a tie” when I win

@bsandusky: There’s some sort of weird bug. Screenshot attached. I played on the bottom left and this appeared.

How did you manage to win? Can you post the sequence of the moves?

Me: left side.
C: center.
Me: top side,
C: Bottom right
Me: Top left (now I have both top left and top side or top left and left side
C: bottom left
Me: Complete the top row, I get “It’s a tie” :slight_smile:

1 Like

Thank you :slight_smile:
Corrected.

Project Link – http://codepen.io/Velenir/full/BzJvyB/
Finally done. Spent way too long on minmax algorithm though.

Project link - [https://codepen.io/Josh5231/pen/oLwZzL]
(https://codepen.io/Josh5231/pen/oLwZzL)

Here’s mine. It’s not unbeatable but it’s solid.

@Velenir : Can’t play it. Nothing happens when I click on X or O to choose player.

Here’s mine:

http://codepen.io/IreneNaya/full/xOPkEm/

I didn’t want to go full AI because I don’t really like the idea of an unbeatable game, so there’s a few ways in which you can win. Let me know if you find any issues, bugs, etc.

That’s strange. I can’t reproduce this behaviour in Chrome or Firefox no matter what. What browser are you using? Are there any errors in the console?
Could anyone else please take a look and report whether it works?

Chrome on a Mac
The developer console says: “Uncaught SyntaxError: missing ) after argument list” and it points to (somewhere near) line 13 of the js

Even more strange now. One would think a missing “)” would throw an Error in every browser. I can only think of my rather heavy ES6 usage as the culprit.
I’ve enabled Babel in preprocessors, maybe it’ll fix something. Please give it another try.

If you are fast enough, you can win before AI even makes a move :slight_smile:

@jenovs: Ha! You’re quick!!! :smiley:

I reduced the timeout for the AI to play. Let me know if you still manage to win. I am trying to think of a way to disallow clicks when the AI has to play, but i’m not sure how to do that inside the loop. I’ll give it a thought. Thanks for the feedback!!

Its really appreciative and Hats Off for your hard strive.

http://codepen.io/mkarabashev/full/kXEjgm/ This here is my next to final version of my tic tac toe game :smiley: It’s next to final because potato phones will probably need alpha beta pruning and therefore I should probably put it in there. I spend a lot of time working on the animations so I’m curious to know what you think. Do they work well together? Are they taking too long? Do they render correctly? That sort of thing. Feedback would be greatly appreciated.

@irenenaya you can disallow clicks by having a turn flag. In my case I have a turnAI flag that holds true when the ai has to play and false otherwise. Clicks don’t work when the flag is true and the ai doesn’t move when the flag is false

@mkarabashev: I can’t run yours. I get an error in the console as soon as it loads: GET http://s.codepen.io/boomerang/db106f4db7afad0ed15bcb3f2bc8aec91469305824242/bundle.js 404 (Not Found)
Nothing happens when i try clicking on the “start new game” button. If i click on the “X” or “O” buttons I get an: object.assign is not a function error. I’m on Chrome 43.x on a Mac.

Thanks for the tip on the flags. It makes lots of sense! :slight_smile:

Thanks for the info. Bundle.js was left forgotten after copy/pasting the code. Same thing with object assign. I think it should work now