コード例 #1
0
        private void InitKingAttacks()
        {
            var kingAttacks = new SquareFlag[64];

            for (var squareIndex = 0; squareIndex < 64; ++squareIndex)
            {
                kingAttacks[squareIndex] = AttackGenerator.GeneratePotentialKingAttacks(squareIndex);
            }

            KingAttacks = kingAttacks;
        }
コード例 #2
0
        private void InitPaths()
        {
            var paths = new SquareFlag[64][];

            for (var squareIndex = 0; squareIndex < 64; ++squareIndex)
            {
                paths[squareIndex] = AttackGenerator.GeneratePaths(squareIndex);
            }

            Paths = paths;
        }
コード例 #3
0
        private void InitPawnCaptures()
        {
            var pawnCapturesWhite = new SquareFlag[64];
            var pawnCapturesBlack = new SquareFlag[64];

            // You could potentially use a smaller range EXCEPT that Kings use this from ranks 1 and 8
            for (var squareIndex = 0; squareIndex < 64; ++squareIndex)
            {
                pawnCapturesWhite[squareIndex] = AttackGenerator.GeneratePotentialWhitePawnCaptures(squareIndex);
                pawnCapturesBlack[squareIndex] = AttackGenerator.GeneratePotentialBlackPawnCaptures(squareIndex);
            }

            PawnCapturesWhite = pawnCapturesWhite;
            PawnCapturesBlack = pawnCapturesBlack;
        }
コード例 #4
0
        private void AddBishopAttack(SortedDictionary <int, SquareFlag> dictionary, int squareIndex, SquareFlag currentOccupancy)
        {
            var magicIndex = MagicIndexHelpers.GetBishopMagicIndex(squareIndex, currentOccupancy);

            var attack = AttackGenerator.GeneratePotentialBishopAttacks(squareIndex, currentOccupancy);

            var indexTaken = dictionary.ContainsKey(magicIndex) && dictionary[magicIndex] != attack;

            if (indexTaken)
            {
                throw new Exception($"Magic Index {magicIndex} already in use by a different attack");
            }

            dictionary[magicIndex] = attack;
        }