From fc3ebd856b19161ce47cc3e1010a12f08025f505 Mon Sep 17 00:00:00 2001 From: Michael Captain Date: Sat, 10 Apr 2021 00:22:53 +0300 Subject: [PATCH] Add comptime arrays for number of relative occupancies --- src/attack.zig | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/attack.zig b/src/attack.zig index 7101812..a5d0cec 100644 --- a/src/attack.zig +++ b/src/attack.zig @@ -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; + } +} -- 2.45.2