示例#1
0
        public void StartGame(Board initialBoard, Sides side, TimeControl timeControl)
        {
            _Board                   = initialBoard;
            _OurSide                 = side;
            _TimeControl             = timeControl;
            _TimeControl.TimeToMove += _TimeControl_TimeToMove;

            _IsGameStopped  = false;
            _ThinkingThread = new Thread(ThinkAboutGame);
            _ThinkingThread.Start();
        }
示例#2
0
        public void Analyze(Board board, TimeControl timeControl)
        {
            _Board                   = board;
            _OurSide                 = _Board.Side;
            _TimeControl             = timeControl;
            _TimeControl.TimeToMove -= _TimeControl_TimeToMove;
            _TimeControl.TimeToMove += _TimeControl_TimeToMove;

            Thread t = new Thread(PonderOurBoard);

            t.Start();
        }
示例#3
0
        public double Run(Brain brain, double secondsPerMove)
        {
            TimeControl timeControl = new TimeControl(TimeControl.TimeControlTypes.SecondsPerMove, secondsPerMove);

            timeControl.MoveMade += new TimeControl.MoveDelegate(timeControl_MoveMade);

            int totalTests  = 0;
            int passedTests = 0;

            foreach (KeyValuePair <string, List <string> > epd in _EPDs)
            {
                Board board = Board.FromFEN(epd.Key);

                brain.Analyze(board, timeControl);

                _WaitForMove.WaitOne();

                string algebraic = brain.BestMove.ToAlgebraic(board);
                bool   passed    = epd.Value.Exists(bm => bm.StartsWith(algebraic));

                totalTests++;
                if (passed)
                {
                    passedTests++;
                }

                string bestMoves = string.Join(", ", epd.Value);

                Console.WriteLine(string.Format("Nodes Per Second: {0}", (int)(brain.NodesEvaluated / timeControl.LastMoveTimeUsed)));
                Console.WriteLine(string.Format("  Suggested Move: {0}", algebraic));
                Console.WriteLine(string.Format("       Best Move: {0}", bestMoves.Trim().Trim(',')));
                Console.WriteLine(string.Format("           Score: {0}/{1}", passedTests, totalTests));
                Console.WriteLine();
            }

            double percent = 100 * (double)passedTests / totalTests;

            Console.WriteLine();
            Console.WriteLine(string.Format("Passed {0:0.0}% of tests.", percent));

            return(percent);
        }