本文整理匯總了C#中System.Clock.Stop方法的典型用法代碼示例。如果您正苦於以下問題:C# Clock.Stop方法的具體用法?C# Clock.Stop怎麽用?C# Clock.Stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Clock
的用法示例。
在下文中一共展示了Clock.Stop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Search
public override SearchResult Search(Board board, int color,int depth)
{
SearchResult searchResult = new SearchResult();
//board.CurrentColor = color;
//PrepareToSolve(board);
int alpha = -MaxScore - 1;
int beta = MaxScore + 1;
int opp = color.Opp();
Clock clock = new Clock();
clock.Start();
//Roulette roulette = new Roulette();
//board.RefreshHash();
int score = -MaxScore;
int eval;
//是否調用零窗口的標誌
bool foundPv = false;
var moves = rule.FindFlips(board, color).ToList();
if (moves.Count == 0) {
return new SearchResult() { Move = -1 };
}
//if (moves.Count == 1) {
// return new SearchResult() { Move = moves.First().Pos };
//}
for (int i = 0; i < moves.Count; i++) {
var pos = moves[i].Pos;
//下棋
//---------------------------
int flipCount = board.MakeMove(pos, color);
searchResult.Nodes++;
//檢測
if (foundPv) {
//調用零窗口
eval = -FastestFirstSolve(board, -alpha - 1, -alpha, depth - 1, searchResult, opp, color);
if ((eval > alpha) && (eval < beta)) {
eval = -FastestFirstSolve(board, -beta, -eval, depth - 1, searchResult, opp, color);
//eval = -FastestFirstMidSolve( -beta, -alpha, oppcolor, depth - 1);
}
}
else {
eval = -FastestFirstSolve(board, -beta, -alpha, depth - 1, searchResult, opp, color);
}
//em.ReLink();
//---------------------------
//Eval.StepsPop(color);
//恢複到上一步
board.Reback(pos, flipCount, opp);
searchResult.Message += string.Format("({0}:{1})", pos, eval);
if (eval > score) {
score = eval;
//更新位置
searchResult.Move = pos;
searchResult.Score = score;
if (eval > alpha) {
if (eval >= beta) {
//剪枝
break;
}
alpha = eval;
foundPv = true;
}
}
}
clock.Stop();
searchResult.TimeSpan = clock.Elapsed;
return searchResult;
}