コード例 #1
0
ファイル: AlfaBeta.cs プロジェクト: Alfilchess/Engine
        public static string uci_pv(cPosicion pos, int depth, val alpha, val beta)
        {
            StringBuilder s = new StringBuilder();
              long elaspsed = cReloj.Now() - SearchTime + 1;
              int uciPVSize = Math.Min(cMotor.m_mapConfig["MultiPV"].Get(), RootMoves.Count);
              int selDepth = 0;
              for (int i = 0; i < cMotor.m_Threads.Count; ++i)
            if (cMotor.m_Threads[i].m_nMaxPly > selDepth)
              selDepth = cMotor.m_Threads[i].m_nMaxPly;
              for (int i = 0; i < uciPVSize; ++i)
              {
            bool updated = (i <= PVIdx);
            if (depth == 1 && !updated)
              continue;
            int d = (updated ? depth : depth - 1);
            if (RootMoves[i].m_PV.Count > 0 && RootMoves[i].m_PV[0] != cMovType.MOV_NAN && 0 < d)
            {
              val v = (updated ? RootMoves[i].m_nVal : RootMoves[i].m_LastVal);
              if (s.Length != 0)
            s.Append(cTypes.LF);
              /*bool bShow = true;
              for (int j = 0; j < d; ++j)
              {
            if (RootMoves[i].m_PV.Count > j && RootMoves[i].m_PV[j] == cMovType.MOV_NAN)
              bShow = false;
              }*/
              if (RootMoves[i].m_PV[0] != cMovType.MOV_NAN)
              {
            s.Append("info depth ");
            s.Append(d);
            s.Append(" score ");
            s.Append((i == PVIdx ? cUci.Puntos(v, alpha, beta) : cUci.Puntos(v, -cValoresJuego.INFINITO, cValoresJuego.INFINITO)));
            s.Append(" nodes ");
            s.Append(pos.GetNodos());
            s.Append(" nps ");
            s.Append((pos.GetNodos() * 1000 / (UInt64)elaspsed).ToString());
            s.Append(" time ");
            s.Append(elaspsed);
            s.Append(" cpuload ");
            s.Append(Program.m_CPU.Get() * 10);
            s.Append(" hashfull ");
            s.Append(cMotor.m_TablaHash.HashFullPercent());
            //if (bShow)
            {
              if (i > 0)
              {
                s.Append(" multipv ");
                s.Append(i + 1);
              }
              s.Append(" pv");

              for (int j = 0; RootMoves[i].m_PV.Count > j && RootMoves[i].m_PV[j] != cMovType.MOV_NAN && j < d; ++j)
              {
                s.Append(" ");
                s.Append(cUci.GetMovimiento(RootMoves[i].m_PV[j], pos.IsChess960() != false));
              }
            }
              }
            }
              }
              return s.ToString();
        }