コード例 #1
0
        public Move PassBoard(int[] Positions, int White, int Black)
        {
            this.MyBoard = new Board(Player.Neutral);

            this.MyBoard.FillTheBoard(Positions, Black, White);
            this.MyEvalDelegate = this.MyBoard.Evaluate;

            return(this.ComputerMove(this.MyEvalSettings, this.MyBoard.Evaluate));
        }
コード例 #2
0
        // function to perform a computer move on the board
        public Move ComputerMove(EvalSettings EvalSettings, EvaluationBoardDelegate EvalBoardDelegate)
        {
            Move ret = null;

            MyEvalBoardDelegate = EvalBoardDelegate;
            Console.WriteLine("Determining computer's move...");
            Move.OurMovesGenerated = 0;

            GameNode gameNode = BestMove(EvalSettings);

            if (gameNode == null)
            {
                if (this.MyBoard.HasWon(Player.Black))
                {
                    Console.WriteLine("Black has won!");
                }
                else if (this.MyBoard.HasWon(Player.White))
                {
                    Console.WriteLine("White has won!");
                }
                // this next bit is because we didn't find a move.  I'm guessing it's because we're only a move or two away
                // from losing.  So get the list of moves and just toss out the first one.
                else
                {
                    Console.WriteLine("No best move found. You may be about to win!");
                    Move[] moveList = this.MyBoard.GetMoves();

                    if (moveList[0] != null)
                    {
                        this.MyBoard.Move(moveList[0]);
                        ret = moveList[0];
                        for (int i = 0; moveList[i] != null && i < Board.MAX_MOVES; i++)
                        {
                            moveList[i].Dispose();
                        }
                    }
                    else
                    {
                        ret = null;
                    }
                    // Delete
                    moveList = null;
                }
            }
            else
            {
                Console.WriteLine("Score: {0}", gameNode.Score);
                this.MyBoard.Move(gameNode.Move);
                ret = gameNode.Move;
            }
            return(ret);
        }