Please play my tic tac toe game and tell me what needs adjusting. https://codepen.io/Stabat/full/raOYmVL
Looking good!
Nice implementation of minimax
I also like that you have X and O take turns of who goes first.
I love the glowing effect of the yellow highlighting.
I see you have a similar problem to mine, using minimax gets a bit slow on a 5x5 board and there is a big delay when you click. It doesn’t show the player move until the compute move has been calculated and then it shows both. This is something I also need to fix in my implementation.
When I choose my symbol at the beginning it’s not highlighted when I click it, it would be nice to indicate what I’ve chosen
In my own implementation I made the win length equal to the board size (5x5 is 5 in a row to win) but when I search now I notice most make it less, as you have done… I did base mine off of this 3d tictactoe which is 4x4x4 and win length is 4.
In wikipedia it does say “One can play on a board of 4x4 squares, winning in several ways. Winning can include: 4 in a straight line, 4 in a diagonal line, 4 in a diamond, or 4 to make a square.” wiki but there are all sorts of variations.
I’m just wondering what rationale you are following for win length?
I did run across some buggy games:
It would be nice if I could see what difficulty I’m playing on.
I’ll do some more testing to see what else fails like this. Overall great work though.
I’m also looking for feedback on my own tic tac toe game: https://forum.freecodecamp.org/t/multi-dimensional-tic-tac-toe/756046
This was on medium difficulty, computer went first, I was X
I also like that you went for 4x4 and 5x5 boards, to make it more interesting.
Thank you very much for the detailed review. I appreciate.
I have corrected the delay move in the hard difficulty mode by wrapping the computermover function in a delay inside the makemove function. Obviously it can’t take away the delay the computer takes to make its own move but it updates player move while waiting for the algorithym Minimax to calculate it’s next move.
I equally corrected the symbol not highlighting in the begining. That completely escaped my view.
It is now showing the difficulty level inside the playing board.
I have been trying to load your own links but it takes too long to load and breaks. I’ll keep trying and give you my own reviews. Thank you very much.
Nice, those changes work well.
There is definitely something wrong with the medium difficulty win detection. Also when this happens the game does not clear itself automatically as it does on easy, it just stays like this until I hit “reset game”
Also on the hard difficulty on 5x5 The computer just selects squares in order starting from the top left
In my experience this is because the depth of minimax is too low. However if you increase the depth it gets a lot slower, I had the same problem. The good news is that you can fix this adding Alpha Beta pruning to your minimax algorithm
Oh no! I wonder what’s wrong…
Thank you very much for the Alpha Beta pruning tweak. I added a little to something to computermove function for hard to block any immediate win move and now it reduces thinking(delay) time for computer move if you are close to winning. Now I can’t win a single game in Hard on 4 and 5 boards. Tell me if you can . I had to change the winning rule for 4 to 4 in a line because whoever played first was likely to win.
I did not understand the problem with medium difficulty you brought up because I am unable to experience it after many rounds of playing. Is there a condition that triggers it ?
One thing I did to speed up the computer move: A quick check to see if the center square (on 3x3 or 5x5 boards) is free and take it if free. That makes a really fast first move and it’s a “no brainer” since the center square is the most “powerful” position.
I’m not sure it seemed to be happening every time for me. I wonder if it’s some difference with our computers.