Beginner needs help: unclear behaviour of a self written function (Minimax)

I did something similar with normal 2D TicTacToe (or someone (Jose, see pps) from the forum did and I played with it tbh) (and also normal 3D TicTacToe with 3 pieces / fields to win (not 4)). No minimax though, something less fancy.
See My program isn't doing what I want it to do (x and o game / Tic Tac Toe) - #69 by Chrisir

Here we had several criteria in a function that evaluated the fitness of the moves:

  • make a move where yourself win
  • make a blocking move to hinder your opponent from winning
  • achieve a fork
  • hinder a fork from your opponent etc.

Do you have this / something similar? I think you should have this “evaluation function”.

My point is (because you wrote “just not as the only one”): when all criteria have the same weight (importance) sometimes, the wrong move is selected: Too many moves come in the list of moves.

Instead, you can multiply each criteria with a value between 0 and 100. First criteria must have 100, 2nd 80 or whatever and so forth, to make a distinction. Because in the final list of moves (from which we then choose randomly) only the moves should appear where you can win (and no other moves) (when you can win in the first place). So only the moves should appear where the score is the current maximum. To achieve this you need different weight (importance) by which you multiply.

Not really easy to express this stuff verbally. :wink:

without looking at your code tbh

Great project!

Warm regards,

Chrisir

:wink:

p.S.
for completeness: when I make such an Game AI, I let it play against a random player (making random but legal moves) 10.000 games. In normal TicTacToe, the Game AI shouldn’t loose ONE game, have a lot of success and only some draws. But it’s a good way to automatically test your Game AI. It won’t work as well in your case because the board is much bigger though.

P.S.S.
see My program isn't doing what I want it to do (x and o game / Tic Tac Toe)

1 Like