public Eval AddPV(Eval mAlpha, Eval mValue, Move move, List <Move> line) { var bWTM = WTM(); //[Lock]UCI may change this at any time. See GameState.newVariations() var bHasValue = 0 < State.VariationCount; var bGrow = State.VariationCount < State.MultiPVLength; if (bGrow) { State.VariationCount++; } var bRoomToGrow = State.VariationCount < State.MultiPVLength; var vn = State.Variation; var nFinal = State.VariationCount - 1; var bPlace = bGrow || bHasValue && mValue > vn[nFinal].Value; if (bPlace) { vn[nFinal].Value = mValue; bHasValue = true; if (vn[nFinal].Moves is null) { vn[nFinal].Moves = new List <Move>(); } var lineMoves = vn[nFinal].Moves; lineMoves.Clear(); if (!isDefined(move)) { Debug.Assert(isDefined(move), "Undefined Move [AddPV]"); move = Move.NullMove; } lineMoves.Add(move); var bPonder = line.Count > 0; //!bChildFinal if (bPonder) { lineMoves.AddRange(line); } // // Insert at correct position: // var nPlace = vn.Insert(nFinal); if (nPlace == 0) { var sb = new StringBuilder(); var mEval = reflectValue(bWTM, mValue); sb.UpdateBestInfo(State.BestMoves, lineMoves, mEval, bPonder, State.Rule) .FlushLine(); } #if DebugPlace if (UCI.IsDebug) { var sb = new StringBuilder(); var sGrow = bGrow ? "Placed" : "Replaced"; sb.AppendFormat($"{sGrow} vn[{nPlace}]"); LogInfo(Level.note, sb.ToString()); sb.Clear(); State.MovePosition.writePV(sb, nPlace, bWTM); } #endif } // // Avoid raising Alpha until we have a candidate for the weakest Variation: // return(bRoomToGrow ? mAlpha : bHasValue?vn[nFinal].Value : mValue); }
internal static UInt32 captured(Move move) { return((UInt32)move >> nCaptiveBit & vPieceMask); }
internal static UInt32 promoted(Move move) { return((UInt32)move >> nPromoteBit & vPieceMask); }
internal static Int32 to(Move move) { return((Int32)move >> nToBit & (Int32)uSquareMask); }
private static UInt32 moved(Move move) { return((UInt32)move >> nPieceBit & vPieceMask); }
internal static bool isCapture(Move move) { return((move & Move.CaptiveMask) != 0); }
protected static Int32 from(Move move) { return((Int32)move >> nFromBit & (Int32)uSquareMask); }
internal static Boolean isCastles(Move move) { return((move & Move.Castles) != 0); }
internal static Boolean isNullMove(Move move) { return((move & Move.NormalMask) == Move.NullMove); }
internal static Boolean isEmptyMove(Move move) { return((move & Move.NormalMask) == Move.EmptyMove); }
internal static Boolean isDefined(Move move) { return((move & Move.NormalMask) != Move.Undefined); }
internal static Boolean isDefinite(Move move) { return(isDefined(move) && !isEmptyMove(move)); }