Example #1
0
        //---------------------------------------------------------------------------------
        public static mov GetFromUCI(cPosicion pos, string str)
        {
            if (str.Length == 5)
              {
            char[] strChar = str.ToCharArray();
            strChar[4] = char.ToLower(strChar[4]);
            str = new String(strChar);
              }

              for (cReglas it = new cReglas(pos, cMovType.LEGAL); it.GetActualMov() != cMovType.MOV_NAN; ++it)
            if (str == GetMovimiento(it.GetActualMov(), pos.IsChess960() != false))
              return it.GetActualMov();

              return cMovType.MOV_NAN;
        }
Example #2
0
        //------------------------------------------------------------------------------------
        public mov Buscar(cPosicion posicion)
        {
            mov move = cMovType.MOV_NAN;
              if (Open())
              {
            cLibro.stLineaLibro lineaLibro = new cLibro.stLineaLibro();
            UInt16 bMejorJugada = 0;
            uint sum = 0;

            hash key = PolyglotKey(posicion);

            m_Stream.Seek(FindFirst(key) * SIZE_OF_BOOKENTRY, SeekOrigin.Begin);
            while (Read(ref lineaLibro) && lineaLibro.key == key)
            {
              bMejorJugada = Math.Max(bMejorJugada, lineaLibro.count);
              sum += lineaLibro.count;

              if ((sum != 0 && ((((uint)m_Rand.GetRand()) % sum) < lineaLibro.count)) || (lineaLibro.count == bMejorJugada))
            move = (lineaLibro.move);
            }

            if (move != 0)
            {
              int pt = (move >> 12) & 7;

              if (pt != 0)
            move = cTypes.CreaMov(cTypes.GetFromCasilla(move), cTypes.GetToCasilla(move), cMovType.PROMOCION, (pt + 1));

              for (cReglas listaMovimientos = new cReglas(posicion, cMovType.LEGAL); listaMovimientos.GetActualMov() != cMovType.MOV_NAN; ++listaMovimientos)
            if (move == (listaMovimientos.GetActualMov() ^ cTypes.TipoMovimiento(listaMovimientos.GetActualMov())))
            {
              move = listaMovimientos.GetActualMov();
              break;
            }
            }
              }
              return move;
        }