コード例 #1
0
ファイル: NodeCounter.cs プロジェクト: respel/Chess22kDotNet
        public static void Main()
        {
            var cb = ChessBoardInstances.Get(0);

            MainEngine.MaxDepth             = MaxPly;
            UciOut.NoOutput                 = true;
            EngineConstants.Power2TtEntries = 2;
            TtUtil.Init(false);
            long totalNodesSearched = 0;

            var epdStrings = BestMoveTest.GetEpdStrings("Resources/WAC-201.epd");

            for (var index = 0; index < NumberOfPositions; index++)
            {
                Console.WriteLine(index);
                var epdString = epdStrings[index + 20];
                Statistics.Reset();
                var epd = new Epd(epdString);
                ChessBoardUtil.SetFen(epd.GetFen(), cb);
                SearchUtil.Start(cb);
                totalNodesSearched += ChessBoardUtil.CalculateTotalMoveCount();
            }

            Console.WriteLine("Total   " + totalNodesSearched);
            Console.WriteLine("Average " + totalNodesSearched / NumberOfPositions);
        }
コード例 #2
0
        public static void Main()
        {
            var cb = ChessBoardInstances.Get(0);

            ChessBoardUtil.SetFen(FenStandardMiddlegame, cb);
            TimeUtil.SetSimpleTimeWindow(5000);
            TtUtil.Init(false);
            SearchUtil.Start(cb);
            Statistics.Print();
        }
コード例 #3
0
        private static void DoTest(IReadOnlyCollection <string> epdStrings)
        {
            var correctCounter = 0;

            foreach (var epdString in epdStrings)
            {
                var epd = new Epd(epdString);
                var cb  = ChessBoardInstances.Get(0);
                ChessBoardUtil.SetFen(epd.GetFen(), cb);

                TimeUtil.Reset();
                TimeUtil.SetSimpleTimeWindow(5000);
                SearchUtil.Start(cb);

                var bestMove = new MoveWrapper(ThreadData.GetBestMove());
                if (epd.IsBestMove)
                {
                    if (epd.MoveEquals(bestMove))
                    {
                        Console.WriteLine(epd.GetId() + " BM OK");
                        correctCounter++;
                        _positionTestOk++;
                    }
                    else
                    {
                        Console.WriteLine(epd.GetId() + " BM NOK " + bestMove + " - " + epd);
                        _positionTestNok++;
                    }
                }
                else
                {
                    if (epd.MoveEquals(bestMove))
                    {
                        Console.WriteLine(epd.GetId() + " AM NOK " + epd);
                        _positionTestNok++;
                    }
                    else
                    {
                        Console.WriteLine(epd.GetId() + " AM OK");
                        correctCounter++;
                        _positionTestOk++;
                    }
                }
            }

            Console.WriteLine(correctCounter + "/" + epdStrings.Count);
        }
コード例 #4
0
        private static void SearchTask()
        {
            try
            {
                var source = new CancellationTokenSource();
                Task.Run(async() => await MaxTimeTask(source.Token), source.Token);
                Task.Run(async() => await InfoTask(source.Token), source.Token);
                _maxTimeExceeded = false;
                SearchUtil.Start(_cb);

                // calculation ready
                source.Cancel();

                UciOut.SendBestMove(_threadData);
            }
            catch (Exception e)
            {
                ErrorLogger.Log(_cb, e, true);
            }
        }