Example #1
0
        static void Main(string[] args)
        {
            char[]  type = TinhToan.getType(@"data/Type.txt");
            MiniMax m    = new MiniMax(type[0], type[1]);

            char[,] board = TinhToan.readFile(@"data/board.txt");
            int level = TinhToan.getLevel(@"data/level.txt");

            m.setBoard(board);
            int[] move = m.findBestMove(level);
            Console.WriteLine(move[0].ToString() + "|" + move[1].ToString());
            TinhToan.setBoard(move, board, type[0]);
            TinhToan.printBoard(board);
            TinhToan.writeNextMove(move, @"data/nextMove.txt");
        }
        public void setMove(int[] move, char type)
        {
            int x = move[0];
            int y = move[1];

            if (type == 'X')
            {
                if (this.game_board[y, x] == '#')
                {
                    this.cacNuocDaDiX.Insert(0, move);
                    this.game_board[y, x] = 'X';
                }
                else if (type == 'O')
                {
                    if (this.game_board[y, x] == '#')
                    {
                        this.cacNuocDadiO.Insert(0, move);
                        this.game_board[y, x] = 'O';
                    }
                }
            }
            TinhToan.printBoard(this.game_board);
        }