Beispiel #1
0
        private static void Divide(byte color, int depth, Board board)
        {
            int total = 0;
            int temp = 0;
            int NumMoves = 0;

            MoveList moves = new MoveList();
            MoveGenerator.GetLegalMoves(color, moves.moves, ref moves.Length, board);

            Console.WriteLine("Move\tNodes");

            for (int i = 0; i < moves.Length; i++)
            {
                board.MakeMove(moves.moves[i]);
                temp = Perft(color.GetOpposite(), depth - 1, board);
                total += temp;
                Console.WriteLine("{0} {1} ", moves.moves[i].ToAlgebraic(), temp);
                board.UndoMove(moves.moves[i]);
                NumMoves++;
            }

            Console.WriteLine("Total Nodes: {0}", total);
            Console.WriteLine("Moves: {0}", NumMoves);
        }
Beispiel #2
0
        private static int Perft(byte color, int depth, Board board)
        {
            MoveList moves = new MoveList();
            MoveGenerator.GetLegalMoves(color, moves.moves, ref moves.Length, board);

            int nodes = 0;

            if (depth == 1)
            {
                return moves.Length;
            }

            if (depth == 0)
                return 1;

            //if (moves.Length == 0)
            //    return 1;

            for (int i = 0; i < moves.Length; i++)
            {
                //if (moves.moves[i].IsCapture())
                //    cap++;
                board.MakeMove(moves.moves[i]);
                nodes += Perft(color.GetOpposite(), depth - 1, board);
                board.UndoMove(moves.moves[i]);
            }

            return nodes;
        }