Hi! could you guys help me check if it works properly? Any kind of feedback is welcome.
I don’t think my algorithm is the most efficient and I might try to optimize it later on. For now I was just trying to make it work.
By the way, I implemented the bonus user story from the video and there’s no way the user can beat the computer. At best it will be a tie. Unless there’s a mistake I haven’t found.
You can play it here: https://codepen.io/jsJoao/full/XajoGN
Hmm i play square 4 comp plays 5
i play 2 comp plays 8
i play 1 and then board lights up all my x disappear before x is put in box
and it show comp with circle in 5,8,3,7 … oops
will look at further moves now
It stopped working after I placed my second move. It worked to a tie the first time through but I repeated the same first and second moves the second time around and it locked.
My first move was in the upper left square as shown.
unfortunately it over writes my moves with its own moves and i can overwrite his moves by clicking on his squares
Thanks. I was changing some things in the code now and that probably affected. But yeah JohnL3, I just realized I forgot to check if the square already has an X or O in some cases. Will do it now.
Rickstewart I had forgotten to reset one of the variables related to the board status when the game is over.
I updated it. Now the user can’t overwrite moves and it’s working better. But I still need to work on the reset function. Thanks for the feedback. That was very helpful.