当前位置: 首页>>代码示例>>C#>>正文


C# Board.SubtractMove方法代码示例

本文整理汇总了C#中Board.SubtractMove方法的典型用法代码示例。如果您正苦于以下问题:C# Board.SubtractMove方法的具体用法?C# Board.SubtractMove怎么用?C# Board.SubtractMove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board.SubtractMove方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AlphaBeta

        public static int AlphaBeta(Board board, int depth, int alpha, int beta, Move? bestMove)
        {
            // Check for end of search or terminal node
            if (depth == 0 || board.WhiteKing == Definitions.EMPTY || board.BlackKing == Definitions.EMPTY)
            {
                _nodesSearched++;
                int resultant = Quiescence(board, alpha, beta);
                //_transTable[board.ZobristHash] = new Transposition.Node(resultant, _ply);
                return resultant;
            }

            List<Move> moveList = board.GenerateMoves();

            // Put captures at the top of the list
            int count = moveList.Count, beginningOfList = 0;
            Move tempMove;
            for (int i = 0; i < count; i++)
            {
                if ((moveList[i].Bits & 1) != 0)
                {
                    tempMove = moveList[i];
                    moveList[i] = moveList[beginningOfList];
                    moveList[beginningOfList] = tempMove;
                    beginningOfList++;
                }
            }

            // Put the previous best move at the top of the list
            if (bestMove.HasValue && moveList.Contains(bestMove.Value))
            {
                moveList.Remove(bestMove.Value);
                moveList.Insert(0, bestMove.Value);
            }

            foreach (Move move in moveList)
            {
                if (!board.AddMove(move)) continue;
                _ply++;
                int result = -AlphaBeta(board, depth - 1, -beta, -alpha, null);
                _ply--;
                board.SubtractMove();

                if (result > alpha)
                {
                    alpha = result;
                    _principleVariation[_ply] = move;
                }

                if (beta <= alpha)
                    break;
            }

            return alpha;
        }
开发者ID:freemanirl,项目名称:fiasco,代码行数:54,代码来源:Search.cs

示例2: Minimax

        static public ulong Minimax(Board board, int depth)
        {
            ulong nodes = 0;
            if (depth == 0) return 1;
            List<Move> moves = board.GenerateMoves(board.Turn);

            foreach (Move move in moves)
            {
                if (board.AddMove(move))
                {
                    nodes += Minimax(board, depth - 1);
                    board.SubtractMove();
                }
            }

            return nodes;
        }
开发者ID:freemanirl,项目名称:fiasco,代码行数:17,代码来源:Perft.cs

示例3: Divide

        static public void Divide(Board board, int depth)
        {
			DateTime start = DateTime.Now;
            Console.WriteLine("Divide() for depth " + depth);
            Console.WriteLine("--------------------");
            List<Move> moves = board.GenerateMoves(board.Turn);
            ulong total = 0;
            foreach (Move move in moves)
            {
                if (board.AddMove(move))
                {
                    ulong current = Minimax(board, depth - 1);
                    total += current;
                    Console.WriteLine("  " + Definitions.MoveToString(move) + "    " + current);
                    board.SubtractMove();
                }
            }
			DateTime end = DateTime.Now;
			Console.WriteLine();
            Console.WriteLine("Total:        " + total);
            Console.WriteLine("Time Elapsed: " + (end - start).TotalSeconds + " s");
        }
开发者ID:freemanirl,项目名称:fiasco,代码行数:22,代码来源:Perft.cs

示例4: Quiescence

        private static int Quiescence(Board board, int alpha, int beta)
        {
            int stand_pat = Engine.Eval.Board(board);

            if (stand_pat >= beta)
                return beta;
            if (alpha < stand_pat)
                alpha = stand_pat;

            List<Move> captures = board.GenerateCaptures();
            foreach (Move move in captures)
            {
                if (!board.AddMove(move)) continue;
                int score = -Quiescence(board, -beta, -alpha);
                board.SubtractMove();

                if (score >= beta)
                    return beta;
                if (score > alpha)
                    alpha = score;
            }

            return alpha;

        }
开发者ID:freemanirl,项目名称:fiasco,代码行数:25,代码来源:Search.cs


注:本文中的Board.SubtractMove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。