示例#1
0
文件: Eval.cs 项目: Alfilchess/Engine
        //----------------------------------------------------------------------------------------------------------
        public static void Init(cPosicion pos, cEvalInfo evalInfo, color colr)
        {
            color colorVS = (colr == cColor.BLANCO ? cColor.NEGRO : cColor.BLANCO);
              sq Down = (colr == cColor.BLANCO ? cCasilla.SUR : cCasilla.NORTE);

              evalInfo.m_Clavadas[colr] = pos.pinned_pieces(colr);

              bitbrd b = evalInfo.m_Ataques[colorVS][cPieza.REY] = pos.attacks_from_square_piecetype(pos.GetRey(colorVS), cPieza.REY);
              evalInfo.m_Ataques[colr][cPieza.NAN] = evalInfo.m_Ataques[colr][cPieza.PEON] = evalInfo.m_Peones.GetPeonesAtaques(colr);

              if (pos.GetNum(colr, cPieza.DAMA) != 0 && pos.MaterialPieza(colr) > cValoresJuego.DAMA_MJ + cValoresJuego.PEON_MJ)
              {
            evalInfo.m_ReyAcorralado[colorVS] = b | cBitBoard.Desplazamiento(b, Down);
            b &= evalInfo.m_Ataques[colr][cPieza.PEON];
            evalInfo.m_AtaquesAlRey[colr] = (b != 0) ? cBitBoard.CountMax15(b) : 0;
            evalInfo.m_ZonaDelRey[colr] = evalInfo.m_PesoAtaquesAlRey[colr] = 0;
              }
              else
              {
            evalInfo.m_ReyAcorralado[colorVS] = 0;
            evalInfo.m_AtaquesAlRey[colr] = 0;
              }
        }
示例#2
0
 public void extract_pv_from_tt(cPosicion pos)
 {
     cPosInfo[] estate = new cPosInfo[cSearch.MAX_PLY_PLUS_6];
       for (int i = 0; i < cSearch.MAX_PLY_PLUS_6; i++)
     estate[i] = new cPosInfo();
       cTablaHashStruct tte;
       int st = 0;
       int ply = 1;
       mov m = m_PV[0];
       val expectedScore = m_nVal;
       m_PV.Clear();
       do
       {
     m_PV.Add(m);
     pos.DoMov(m_PV[ply++ - 1], estate[st++]);
     tte = cMotor.m_TablaHash.Buscar(pos.ClaveHash());
     expectedScore = -expectedScore;
       } while (tte != null
       && expectedScore == cSearch.value_from_tt(tte.GetValue(), ply)
       && pos.IsPseudoLegalMov(m = tte.GetMove())
       && pos.IsLegalMov(m, pos.pinned_pieces(pos.ColorMueve()))
       && ply < cSearch.MAX_PLY
       && (!pos.IsTablas() || ply <= 2));
       m_PV.Add(cMovType.MOV_NAN);
       while (--ply != 0)
     pos.DesMov(m_PV[ply - 1]);
 }
示例#3
0
        //----------------------------------------------------------------------------------------
        public static int JugadasLegales(cPosicion pos, cMov[] mlist, int mPos)
        {
            int end, cur = mPos;
              bitbrd pinned = pos.pinned_pieces(pos.ColorMueve());
              sq ksq = pos.GetRey(pos.ColorMueve());

              end=pos.Jaques()!=0 ? Evasiones(pos, mlist, mPos)
                         : Generar(pos, mlist, mPos, cMovType.NON_EVASIONS);
              while(cur!=end)
            if((pinned!=0||cTypes.GetFromCasilla(mlist[cur].m)==ksq||cTypes.TipoMovimiento(mlist[cur].m)==cMovType.ENPASO)
            &&!pos.IsLegalMov(mlist[cur].m, pinned))
              mlist[cur].m=mlist[--end].m;
            else
              ++cur;

              return end;
        }