Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------
        public static void InitMagic(type pt, bitbrd[][] attacks, bitbrd[] magics, bitbrd[] masks, uint[] shifts, sq[] deltas, Funcion index)
        {
            int[][] MagicBoosters = new int[2][]{
               				new int[] { 969, 1976, 2850,  542, 2069, 2852, 1708,  164 },
               		new int[] { 3101,  552, 3555,  926,  834,   26, 2131, 1117 }
            };

              cAleatorio rk = new cAleatorio(4474);
              bitbrd[] occupancy = new UInt64[4096], reference = new UInt64[4096];
              bitbrd edges, b;
              int i, size, booster;

              for (sq s = cCasilla.A1; s <= cCasilla.H8; s++)
              {
            edges = ((cBitBoard.F1 | cBitBoard.F8) & ~cBitBoard.GetFilaS1(s)) | ((cBitBoard.A | cBitBoard.H) & ~cBitBoard.GetColumnaSq(s));

            masks[s] = AtaqueSlide(deltas, s, 0) & ~edges;
            shifts[s] = 32 - (uint)cBitBoard.CountMax15(masks[s]);

            b = 0;
            size = 0;
            do
            {
              occupancy[size] = b;
              reference[size] = AtaqueSlide(deltas, s, b);
              size++;
              b = (b - masks[s]) & masks[s];
            } while (b != 0);

            attacks[s] = new bitbrd[size];
            booster = MagicBoosters[0][cTypes.Fila(s)];

            do
            {
              do magics[s] = rk.NumeroMagico(booster);
              while (cBitBoard.CountMax15((magics[s] * masks[s]) >> 56) < 6);

              Array.Clear(attacks[s], 0, size);

              for (i = 0; i < size; i++)
              {
            bitbrd attack = attacks[s][index(s, occupancy[i], pt)];

            if (attack != 0 && attack != reference[i])
              break;

            attacks[s][index(s, occupancy[i], pt)] = reference[i];
              }
            } while (i != size);
              }
        }
Ejemplo n.º 2
0
 //------------------------------------------------------------------------------------
 public cLibro()
 {
     m_Rand = new cAleatorio((int)(cReloj.Now() % 1000));
 }