Need help with making Tic Tac Toe AI!

Need help with making Tic Tac Toe AI!
0

#1

I’ve been trying to make Tic Tac Toe game for almost a month. I’ve looked at others code and found this one and modified it a bit but it still doesen’t work. When I click on the first tile it says ‘game overX’ and when I click on the other tiles it doesen’t respond. I know that the problem is in this line: board[move.i][move.j] = aiPlayer; but I don’t understand where.

And also is there another way to do this because I don’t understand also the ._minBy and ._maxBy because I found this code online and I want to learn it so later I can change it and implement my own. PLEASE HELP!
Here is the link: https://codepen.io/Teo03/pen/NwWKVm


#3

Should I make an array of winning combinations to test for checkGameOver() function?


#4

Personally I learned about Minimax algorithm after finishing my TTT App, when reviewing other campers sulutions.
So yes, you can do the challenge without Minimax.

Comment I putted above my moveAI method:

/**

  • priorities:
    1. make win move
    1. block enemy win move
    1. block enemy line while making move on own line
    1. just move
  • move priorities:
  • a. center
  • b. corners
  • c. other
    */