pub fn riderBlocker(self: @This(), square: Square, piece: Figures) BoardType {
const rank = @intCast(isize, square.rank());
const file = @intCast(isize, square.file());
const moves = switch (piece) {
.bishop => [_][2]i3{
.{ -1, -1 },
.{ -1, 1 },
.{ 1, -1 },
.{ 1, 1 },
},
.rook => [_][2]i3{
.{ -1, 0 },
.{ 1, 0 },
.{ 0, -1 },
.{ 0, 1 },
},
else => unreachable,
};
var blockers: BoardType = 0;
for (moves) |m| {
var step: i5 = 1;
while (step < SIZE - 1) : (step += 1) {
const dr = rank + m[0] * step;
const df = file + m[1] * step;
if (m[0] > 0 and dr > 7) break;
if (m[0] < 0 and dr < 0) break;
if (m[1] > 0 and df > 7) break;
if (m[1] < 0 and df < 0) break;
const s = @intCast(u6, dr * SIZE + df);
const mask = @intCast(BoardType, @as(BoardType, 1) << s);
blockers |= mask;
if (mask & self.board != 0) break;
}
}
return blockers;
}