diff options
author | eug-vs <eugene@eug-vs.xyz> | 2023-06-26 20:01:36 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2023-06-26 20:01:36 +0300 |
commit | 72761f770a73e3e8fac9b57043ed19f084bfb230 (patch) | |
tree | bc482dc87dfbddd4cd9a71461d37e9dde41cfb45 /src/bitboard.c | |
parent | c3474b1481a02baefda1abe286d4fbef39597bce (diff) | |
download | j1chess-72761f770a73e3e8fac9b57043ed19f084bfb230.tar.gz |
tmp: save progress from @black-pearltmp
Diffstat (limited to 'src/bitboard.c')
-rw-r--r-- | src/bitboard.c | 26 |
1 files changed, 26 insertions, 0 deletions
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; +} |