本文整理汇总了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;
}
示例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;
}
示例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");
}
示例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;
}