예제 #1
0
        private void SetEvaluation(AnalysisEventArgs args)
        {
            if (this.Game.CurrentMove == null)
            {
                return;
            }

            //Set Evaluation value & Depth
            SetPoints(args.Points, args.Depth);

            //Set ExpectedMove value & Depth
            if (!string.IsNullOrEmpty(this.Game.PonderMove))
            {
                string expectedMove = FormatMove(this.Game.PonderMove);
                args.ExpectedMove = expectedMove;

                int index = expectedMove.IndexOf(".");
                if (index >= 0)
                {
                    expectedMove = expectedMove.Substring(index + 1);
                }

                if (this.Game.Player1.IsEngine)
                {
                    this.Game.Player1.Engine.ExpectedMove = expectedMove;
                }

                if (this.Game.Player2.IsEngine)
                {
                    this.Game.Player2.Engine.ExpectedMove = expectedMove;
                }
            }
        }
예제 #2
0
        private void ProcessEvaluations(UCIInfoEventArgs e)
        {
            if (!IsEvaluationsAllowed)
            {
                return;
            }

            AnalysisEventArgs args = new AnalysisEventArgs();

            #region Set Depth,Nps etc.
            if (e.Depth > 0)
            {
                eDepth     = e.Depth.ToString();
                args.Depth = eDepth;
            }

            if (e.NPS > 0)
            {
                args.Rate = (e.NPS / 1000) + " kN/s";
            }
            #endregion

            #region Evaluation Item
            if (!string.IsNullOrEmpty(e.PV))
            {
                args.Points       = GetScore(e);
                args.IsLowerBound = e.IsLowerBound;
                args.IsUpperBound = e.IsUpperBound;

                Moves eMoves;
                eMoves = LoadMoves(e.PV);

                args.Pv = e.PV;

                expectedMove   = this.Game.PonderMove;
                args.Move_Time = expectedMove;

                string stats  = string.Empty;
                string points = GetScore(e);
                stats += points + "  Depth: " + e.Depth + "  ";
                stats += Clock.GetTimeString(e.Time / 1000) + "  ";

                if (e.NPS > 0)
                {
                    stats += (e.NPS / 1000) + " kN/s";
                }

                args.EMoves = GetMovesString(eMoves);

                if (this.UciEngine.IsKibitzer)
                {
                    TestDebugger.Instance.Write("Analysis........:" + args.EMoves);
                }

                args.EStatistics = stats;
            }
            #endregion

            #region ExpectedMove
            if (e.CurrentMoveNumber > 0)
            {
                if (e.CurrentMoveNumber > maxCurrentMoveNumber)
                {
                    maxCurrentMoveNumber = e.CurrentMoveNumber;
                }

                Move m = Move.NewMove();
                m.Game = this.Game;

                if (!this.UciEngine.IsKibitzer)
                {
                    m.MoveNo = currentMoveNumber;
                }
                else
                {
                    if (this.Game.CurrentMove != null)
                    {
                        m.MoveNo = this.Game.CurrentMove.MoveNo;
                    }
                    else
                    {
                        m.MoveNo = 1;
                    }
                }
                if (this.Game.CurrentMove != null)
                {
                    m.IsWhite = this.Game.CurrentMove.IsWhite;
                }
                m.From = e.CurrentMove.Substring(0, 2);
                m.To   = e.CurrentMove.Substring(2, 2);

                //GameWrapper = new GameW(CurrentFen);
                GameWrapper.SetFen(CurrentFen);

                if (!string.IsNullOrEmpty(this.Game.PonderMove) && GameWrapper.IsLegalMove(this.Game.PonderMove) && !this.UciEngine.IsKibitzer)
                {
                    GameWrapper.AppendMove(this.Game.PonderMove);
                }
                m.Piece = Board.PieceFromString(GameWrapper.GetMovingPiece(e.CurrentMove));

                string dot = ".";
                int    correctNextMoveNo = this.Game.NextMoveNo;
                #region Move Formatting
                if (this.Game.CurrentMove != null)
                {
                    if (!this.UciEngine.IsKibitzer)
                    {
                        if (this.Game.Flags.IsInfiniteAnalysisOff)
                        {
                            if (!this.Game.CurrentMove.IsWhite)
                            {
                                dot = "...";
                            }
                            else
                            {
                                correctNextMoveNo++;
                            }
                        }
                        else
                        {
                            if (!this.Game.CurrentMove.IsWhite)
                            {
                                dot = ".";
                            }
                            else
                            {
                                dot = "...";
                            }
                        }
                    }
                    else
                    {
                        if (!this.Game.NextMoveIsWhite)
                        {
                            dot = "...";
                        }
                    }
                }
                #endregion
                string moveDisplay = m.Notation.Substring(m.Notation.IndexOf(".") + 1);

                moveDisplay    = correctNextMoveNo + dot + moveDisplay + "(" + e.CurrentMoveNumber + "/" + maxCurrentMoveNumber + ")";
                args.MoveDepth = moveDisplay;
            }
            #endregion

            #region Set Player's(Engine's) Eval
            SetEvaluation(args);
            #endregion

            #region Fire Event
            if (EvaluationsReceived != null)
            {
                EvaluationsReceived(this, args);
            }
            #endregion
        }