本文整理汇总了C#中Search.setListener方法的典型用法代码示例。如果您正苦于以下问题:C# Search.setListener方法的具体用法?C# Search.setListener怎么用?C# Search.setListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search.setListener方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getCommand
public string getCommand(Position pos, bool drawOffer, List<Position> history)
{
// Create a search object
ulong[] posHashList = new ulong[200 + history.Count];
int posHashListSize = 0;
for(int i=0;i<history.Count;i++)
{
Position p = history[i];
posHashList[posHashListSize++] = p.zobristHash();
}
tt.nextGeneration();
Search sc = new Search(pos, posHashList, posHashListSize, tt);
// Determine all legal moves
MoveGen.MoveList moves = new MoveGen().pseudoLegalMoves(pos);
MoveGen.RemoveIllegal(pos, moves);
sc.scoreMoveList(moves, 0);
// Test for "game over"
if (moves.size == 0) {
// Switch sides so that the human can decide what to do next.
return "swap";
}
if (bookEnabled) {
Move bookMove = book.getBookMove(pos);
if (bookMove != null) {
SystemHelper.printf("Book moves: " + book.getAllBookMoves(pos));
return TextIO.moveTostring(pos, bookMove, true);
}
}
// Find best move using iterative deepening
currentSearch = sc;
sc.setListener(listener);
Move bestM;
if ((moves.size == 1) && (canClaimDraw(pos, posHashList, posHashListSize, moves.m[0]) == "")) {
bestM = moves.m[0];
bestM.score = 0;
} else if (randomMode) {
bestM = findSemiRandomMove(sc, moves);
} else {
sc.timeLimit(minTimeMillis, maxTimeMillis);
bestM = sc.iterativeDeepening(moves, maxDepth, maxNodes, verbose);
}
currentSearch = null;
// tt.printStats();
string strMove = TextIO.moveTostring(pos, bestM, true);
bestmv = bestM;
// Claim draw if appropriate
if (bestM.score <= 0) {
string drawClaim = canClaimDraw(pos, posHashList, posHashListSize, bestM);
if (drawClaim != "")
strMove = drawClaim;
}
return strMove;
}