示例#1
0
        //	Adds a new move evaluation to the adjudicator.
        //	The Result property can be checked after calling this function
        //	to determine if the game should be adjudicated.
        public void AddEval
            (Game game,                                 //	game state following move
            MoveEvaluation eval)                        //	the evaluation of the move
        {
            int side = game.CurrentSide ^ 1;

            //	Tablebase adjudication - NOT IMPLEMENTED YET
            if (tbEnabled)
            {
                //m_result = board->tablebaseResult();
                //if (!m_result.isNone())
                //	return;
            }

            //	Moves forced by the user (e.g., from opening book or played by user)
            if (eval.Depth <= 0)
            {
                drawScoreCount         = 0;
                resignScoreCount[side] = 0;
                return;
            }

            //	Draw adjudication
            if (drawMoveNum > 0)
            {
                if ((eval.Score >= 0 ? eval.Score : -eval.Score) <= drawScore)
                {
                    drawScoreCount++;
                }
                else
                {
                    drawScoreCount = 0;
                }
                if (game.GameMoveNumber / 2 >= drawMoveNum && drawScoreCount >= drawMoveCount * 2)
                {
                    Result = new Result(ResultType.Adjudication, -1);
                    return;
                }
            }

            //	Resign adjudication
            if (resignMoveCount > 0)
            {
                if (eval.Score <= resignScore)
                {
                    resignScoreCount[side]++;
                }
                else
                {
                    resignScoreCount[side] = 0;
                }

                if (resignScoreCount[side] >= resignMoveCount)
                {
                    Result = new Result(ResultType.Adjudication, side ^ 1);
                }
            }
        }
示例#2
0
        // *** CONSTRUCTION *** //

        public Player(IDebugMessageLog messageLog, TimerFactory timerFactory)
        {
            State           = PlayerState.NotStarted;
            this.timer      = timerFactory.NewTimer();
            claimedResult   = false;
            ClaimsValidated = true;
            Game            = null;
            Opponent        = null;
            Evaluation      = new MoveEvaluation();
            MessageLog      = messageLog;
            DebugMessage   += onDebugMessage;

            StartedThinking += delegate { };
            StoppedThinking += delegate { };
            MoveMade        += delegate { };
        }
示例#3
0
        protected static string evalString(MoveEvaluation eval)
        {
            if (eval.IsBookEval)
            {
                return("book");
            }
            if (eval == null)
            {
                return("");
            }

            string str = "";

            if (eval.Depth > 0)
            {
                int score    = eval.Score;
                int absScore = score >= 0 ? score : -score;
                if (score > 0)
                {
                    str += "+";
                }

                // Detect mate-in-n scores
                if (absScore > 9900 &&
                    (absScore = 1000 - (absScore % 1000)) < 100)
                {
                    if (score < 0)
                    {
                        str += "-";
                    }
                    str += "M" + absScore.ToString();
                }
                else
                {
                    str += ((double)score / 100.0).ToString("F2");
                }

                str += "/" + eval.Depth.ToString() + " ";
            }

            long t = eval.Time;

            if (t == 0)
            {
                return(str + "0s");
            }

            int precision = 0;

            if (t < 100)
            {
                precision = 3;
            }
            else if (t < 1000)
            {
                precision = 2;
            }
            else if (t < 10000)
            {
                precision = 1;
            }
            str += ((double)t / 1000.0).ToString("F" + precision.ToString()) + 's';

            return(str);
        }