From 72761f770a73e3e8fac9b57043ed19f084bfb230 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 26 Jun 2023 20:01:36 +0300 Subject: tmp: save progress from @black-pearl --- src/bitboard.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/bitboard.c') diff --git a/src/bitboard.c b/src/bitboard.c index e53e3ed..96f220d 100644 --- a/src/bitboard.c +++ b/src/bitboard.c @@ -35,3 +35,29 @@ inline int bitscanAndReset(Bitboard* bb) { *bb &= *bb - 1; return idx; } + + +/* These 4 blindly copied from chessprogramming.org TODO: rewrite */ +U64 rankMask(enumSquare sq) { + return C64(0xff) << (sq & 56); +} + +U64 fileMask(enumSquare sq) { + return C64(0x0101010101010101) << (sq & 7); +} + +U64 diagonalMask(enumSquare sq) { + const U64 maindia = C64(0x8040201008040201); + int diag =8*(sq & 7) - (sq & 56); + int nort = -diag & ( diag >> 31); + int sout = diag & (-diag >> 31); + return (maindia >> sout) << nort; +} + +U64 antiDiagMask(enumSquare sq) { + const U64 maindia = C64(0x0102040810204080); + int diag =56- 8*(sq&7) - (sq&56); + int nort = -diag & ( diag >> 31); + int sout = diag & (-diag >> 31); + return (maindia >> sout) << nort; +} -- cgit v1.2.3