Пример #1
0
        public static UInt64 GetKingAttacks(UInt64 king)
        {
            UInt64 attacks = BitOps.OneStepEast(king) | BitOps.OneStepWest(king);

            king    |= attacks;
            attacks |= BitOps.OneStepNorth(king) | BitOps.OneStepSouth(king);
            return(attacks);
        }
Пример #2
0
 private static UInt64 GetPawnsAbleToSinglePush(bool isPlayer, UInt64 pawns, UInt64 empty)
 {
     if (isPlayer)
     {
         return(BitOps.OneStepSouth(empty) & pawns);
     }
     else
     {
         return(BitOps.OneStepNorth(empty) & pawns);
     }
 }
Пример #3
0
 private static UInt64 GetSinglePushTargets(bool isPlayer, UInt64 pawns, UInt64 empty)
 {
     if (isPlayer)
     {
         return(BitOps.OneStepNorth(pawns) & empty);
     }
     else
     {
         return(BitOps.OneStepSouth(pawns) & empty);
     }
 }
Пример #4
0
 private static UInt64 GetPawnsAbleToDoublePush(bool isPlayer, UInt64 pawns, UInt64 empty)
 {
     if (isPlayer)
     {
         UInt64 emptyRank3 = BitOps.OneStepSouth(empty & Constants.Ranks.Four) & empty;
         return(GetPawnsAbleToSinglePush(isPlayer, pawns, emptyRank3));
     }
     else
     {
         UInt64 emptyRank6 = BitOps.OneStepNorth(empty & Constants.Ranks.Six) & empty;
         return(GetPawnsAbleToSinglePush(isPlayer, pawns, emptyRank6));
     }
 }
Пример #5
0
        private static UInt64 GetDoublePushTargets(bool isPlayer, UInt64 pawns, UInt64 empty)
        {
            UInt64 singlePush = GetSinglePushTargets(isPlayer, pawns, empty);

            if (isPlayer)
            {
                return(BitOps.OneStepNorth(singlePush) & empty & Constants.Ranks.Four);
            }
            else
            {
                return(BitOps.OneStepSouth(singlePush) & empty & Constants.Ranks.Five);
            }
        }
Пример #6
0
        public static void initRayAttacks()
        {
            UInt64 rayAttack;

            for (byte i = 0; i < 64; i++)
            {
                UInt64 square = 1UL << i;

                //nort
                rayAttack        = BitOps.OneStepNorth(square);
                rayAttack       |= BitOps.OneStepNorth(rayAttack);
                rayAttack       |= BitOps.OneStepNorth(rayAttack);
                rayAttack       |= BitOps.OneStepNorth(rayAttack);
                rayAttack       |= BitOps.OneStepNorth(rayAttack);
                rayAttack       |= BitOps.OneStepNorth(rayAttack);
                rayAttack       |= BitOps.OneStepNorth(rayAttack);
                rayAttacks[0, i] = rayAttack;

                //sout
                rayAttack        = BitOps.OneStepSouth(square);
                rayAttack       |= BitOps.OneStepSouth(rayAttack);
                rayAttack       |= BitOps.OneStepSouth(rayAttack);
                rayAttack       |= BitOps.OneStepSouth(rayAttack);
                rayAttack       |= BitOps.OneStepSouth(rayAttack);
                rayAttack       |= BitOps.OneStepSouth(rayAttack);
                rayAttack       |= BitOps.OneStepSouth(rayAttack);
                rayAttacks[1, i] = rayAttack;

                //east
                rayAttack        = BitOps.OneStepEast(square);
                rayAttack       |= BitOps.OneStepEast(rayAttack);
                rayAttack       |= BitOps.OneStepEast(rayAttack);
                rayAttack       |= BitOps.OneStepEast(rayAttack);
                rayAttack       |= BitOps.OneStepEast(rayAttack);
                rayAttack       |= BitOps.OneStepEast(rayAttack);
                rayAttack       |= BitOps.OneStepEast(rayAttack);
                rayAttacks[2, i] = rayAttack;

                //west
                rayAttack        = BitOps.OneStepWest(square);
                rayAttack       |= BitOps.OneStepWest(rayAttack);
                rayAttack       |= BitOps.OneStepWest(rayAttack);
                rayAttack       |= BitOps.OneStepWest(rayAttack);
                rayAttack       |= BitOps.OneStepWest(rayAttack);
                rayAttack       |= BitOps.OneStepWest(rayAttack);
                rayAttack       |= BitOps.OneStepWest(rayAttack);
                rayAttacks[3, i] = rayAttack;

                //noEa
                rayAttack        = BitOps.OneStepNorthEast(square);
                rayAttack       |= BitOps.OneStepNorthEast(rayAttack);
                rayAttack       |= BitOps.OneStepNorthEast(rayAttack);
                rayAttack       |= BitOps.OneStepNorthEast(rayAttack);
                rayAttack       |= BitOps.OneStepNorthEast(rayAttack);
                rayAttack       |= BitOps.OneStepNorthEast(rayAttack);
                rayAttack       |= BitOps.OneStepNorthEast(rayAttack);
                rayAttacks[4, i] = rayAttack;

                //soWe
                rayAttack        = BitOps.OneStepSouthWest(square);
                rayAttack       |= BitOps.OneStepSouthWest(rayAttack);
                rayAttack       |= BitOps.OneStepSouthWest(rayAttack);
                rayAttack       |= BitOps.OneStepSouthWest(rayAttack);
                rayAttack       |= BitOps.OneStepSouthWest(rayAttack);
                rayAttack       |= BitOps.OneStepSouthWest(rayAttack);
                rayAttack       |= BitOps.OneStepSouthWest(rayAttack);
                rayAttacks[5, i] = rayAttack;

                //noWe
                rayAttack        = BitOps.OneStepNorthWest(square);
                rayAttack       |= BitOps.OneStepNorthWest(rayAttack);
                rayAttack       |= BitOps.OneStepNorthWest(rayAttack);
                rayAttack       |= BitOps.OneStepNorthWest(rayAttack);
                rayAttack       |= BitOps.OneStepNorthWest(rayAttack);
                rayAttack       |= BitOps.OneStepNorthWest(rayAttack);
                rayAttack       |= BitOps.OneStepNorthWest(rayAttack);
                rayAttacks[6, i] = rayAttack;

                //soEa
                rayAttack        = BitOps.OneStepSouthEast(square);
                rayAttack       |= BitOps.OneStepSouthEast(rayAttack);
                rayAttack       |= BitOps.OneStepSouthEast(rayAttack);
                rayAttack       |= BitOps.OneStepSouthEast(rayAttack);
                rayAttack       |= BitOps.OneStepSouthEast(rayAttack);
                rayAttack       |= BitOps.OneStepSouthEast(rayAttack);
                rayAttack       |= BitOps.OneStepSouthEast(rayAttack);
                rayAttacks[7, i] = rayAttack;
            }
        }