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 }
private Moves LoadMoves(string pv) { Moves moves = new Moves(Moves.GetMovesTable()); try { GameWrapper.SetFen(fen); string[] pvMoves = pv.Split(" ".ToCharArray()); int currentMoveNumber = 1; bool isWhite = true; int tempMoveNumber = currentMoveNumber; bool isWhiteMove = isWhite; Move m; foreach (string move in pvMoves) { if (string.IsNullOrEmpty(move)) { continue; } if (GameWrapper.IsLegalMove(move)) { m = App.Model.Move.NewMove(); m.Game = g; m.MoveNo = tempMoveNumber; m.IsWhite = isWhiteMove; m.From = move.Substring(0, 2); m.To = move.Substring(2, 2); m.Piece = Board.PieceFromString(GameWrapper.GetMovingPiece(move)); m.Flags.IsCapture = GameWrapper.IsCapturingMove(move); m.Flags.IsPromotion = GameWrapper.IsPromotionMove(move); m.Flags.IsLongCastling = GameWrapper.IsLongCastlingMove(move); m.Flags.IsShortCastling = GameWrapper.IsShortCastlingMove(move); m.Flags.IsInCheck = GameWrapper.IsCheckingMove(move); m.Flags.IsMated = GameWrapper.IsCheckMatingMove(move); m.Flags.IsStaleMated = GameWrapper.IsStaleMatingMove(move); m.Flags.IsAmbigousMove = GameWrapper.IsAmbiguousMove(move); m.Flags.IsAmbigousMoveColumn = GameWrapper.IsAmbiguousFile(move); m.Flags.IsAmbigousMoveRow = GameWrapper.IsAmbiguousRank(move); if (m.Flags.IsCapture) { m.CapturedPiece = Board.PieceFromString(GameWrapper.GetMovingPiece(move)); } if (m.Flags.IsMated) { m.Flags.IsInCheck = false; } GameWrapper.AppendMove(move); moves.DataTable.ImportRow(m.DataRow); isWhiteMove = !isWhiteMove; if (isWhiteMove) { tempMoveNumber++; } } } } catch (Exception ex) { TestDebugger.Instance.Write(ex); } return(moves); }