當前位置: 首頁>>代碼示例>>C#>>正文


C# Clock.Stop方法代碼示例

本文整理匯總了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;
        }
開發者ID:coolcode,項目名稱:ai,代碼行數:79,代碼來源:EndGameEngine.cs


注:本文中的System.Clock.Stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。