~macaptain/lkdo-chess

fc3ebd856b19161ce47cc3e1010a12f08025f505 — Michael Captain 3 years ago 3d9d797
Add comptime arrays for number of relative occupancies
1 files changed, 28 insertions(+), 0 deletions(-)

M src/attack.zig
M src/attack.zig => src/attack.zig +28 -0
@@ 254,3 254,31 @@ pub fn rookAttackRays(rook: Square, block: u64) u64 {
    }
    return resetBit(bitboard, rook);
}

pub const num_rook_relative_occupancies = numRookRelativeOccupancies();

fn numRookRelativeOccupancies() [64]u64 {
    comptime {
        @setEvalBranchQuota(2000);
        var occupancies: [64]u64 = undefined;
        var i = 0;
        while (i < 64) : (i += 1) {
            occupancies[i] = @popCount(u64, maskRookOccupancy(@intToEnum(Square, i)));
        }
        return occupancies;
    }
}

pub const num_bishop_relative_occupancies = numBishopRelativeOccupancies();

fn numBishopRelativeOccupancies() [64]u64 {
    comptime {
        @setEvalBranchQuota(2000);
        var occupancies: [64]u64 = undefined;
        var i = 0;
        while (i < 64) : (i += 1) {
            occupancies[i] = @popCount(u64, maskBishopOccupancy(@intToEnum(Square, i)));
        }
        return occupancies;
    }
}