Hello, i'm trying to build a tic tac toe with minimax for the past few days and it dosent work properly. at first he blockes me as expected but then he just does mistakes. I think my problem is that when I find moves and their scores i save them in a Dictionary, that way when two moves has the same score only the first goes in the Dictionary (the score is the key and the move is a point and that is the value). Someone has a better way to save the moves and their scores? and maybe suggest a good way to give scores to moves so its less likely that two moves get the same score?
here is my minimax funtion just in case but i think i wrote it right. moves is a Dictionary and myMove is a point.
publicintMiniMax(int[,] board,int depth, bool comTurn){
        bool finalnode =true;for(rows =0; rows < board.GetLength(0); rows++)for(cols =0; cols < board.GetLength(1); cols++){if(board[rows, cols]==0){
                    finalnode =false;break;}}if(depth ==0|| finalnode){returnBoardGrade(board);}if(comTurn){
            bestScore =int.MinValue;for(int rows =0; rows < board.GetLength(0); rows++)for(int cols =0; cols < board.GetLength(1); cols++){if(board[rows, cols]==0){
                        myMove.X = cols;
                        myMove.Y = rows;
                        board[rows, cols]=2;
                        value =MiniMax(board, depth -1,false);
                        bestScore =Math.Max(bestScore, value);if(Moves.ContainsKey(value)==false)Moves.Add(value, myMove);
                        board[rows, cols]=0;}}return bestScore;}else{
            bestScore =int.MaxValue;for(int rows =0; rows < board.GetLength(0); rows++)for(int cols =0; cols < board.GetLength(1); cols++){if(board[rows, cols]==0){
                        board[rows, cols]=1;
                        value =MiniMax(board, depth -1,true);
                        bestScore =Math.Min(bestScore, value);if(Moves.ContainsKey(value)==false)Moves.Add(value, myMove);
                        board[rows, cols]=0;}}return bestScore;}}