Ejemplo n.º 1
0
        /// <summary>
        /// Joue un coup
        /// </summary>
        /// <returns>Un nouvel arbre de coup possible d'après l'état du plateau après le coup joué</returns>
        public TreeNode Apply(int col, int line, bool isWhite)
        {
            Board newBoard = new Board(board);

            newBoard.PlayMove(col, line, isWhite);

            EType newType;

            if (Type == EType.MAX)
            {
                newType = EType.MIN;
            }
            else
            {
                newType = EType.MAX;
            }

            return(new TreeNode(newBoard, newType, this.isWhite));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Test de l'IA en mode console.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            Board boardWhite   = new Board();
            Board boardBlack   = new Board();
            Board boardArbitre = new Board();

            bool finished  = false;
            bool whiteTurn = false;

            while (!finished)
            {
                Board turnBoard = whiteTurn ? boardWhite : boardBlack;

                var move = turnBoard.GetNextMove(boardArbitre.GetBoard(), 4, whiteTurn);

                if (move.Item1 == -1 && move.Item2 == -1)
                {
                    PrintPass(whiteTurn);
                }
                else
                {
                    if (boardArbitre.IsPlayable(move.Item1, move.Item2, whiteTurn))
                    {
                        boardArbitre.PlayMove(move.Item1, move.Item2, whiteTurn);
                        boardBlack.PlayMove(move.Item1, move.Item2, whiteTurn);
                        boardWhite.PlayMove(move.Item1, move.Item2, whiteTurn);
                    }
                    else
                    {
                        PrintError(move, whiteTurn);
                        break;
                    }
                    PrintBoard(boardArbitre.GetBoard(), whiteTurn, move.Item1, move.Item2);
                }
                whiteTurn = !whiteTurn;

                finished = boardArbitre.IsFinished();

                //Console.ReadKey();
            }
            PrintFinish(boardArbitre);
            Console.ReadKey();
        }