-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Heavily inspired by what chessbit does pretty much everywhere. (Which itself was learned this technique from Gigantua)
For example:
https://github.com/thuijbregts/chessbit/blob/boardstate_stats/chessbit/MoveGenerator.h
template <bool side>
ForceInline U64 pawnsAtkForward(U64 pM) {
if constexpr (side == white) return pM >> 8;
return pM << 8;
}Removes the if at runtime!
This entire functions gets compiled down to a rightshift for white and leftshift for black and nothing else (maybe a few moves).
In rust we can do the same by writing something like this:
#[inline(always)]
pub const fn pawns_atk_forward<const SIDE: bool>(pawn_mask: u64) -> u64 {
if SIDE {
pawn_mask >> 8 // White
} else {
pawn_mask << 8 // Black
}
}Applying this pattern all over the code base should result in incredible performance gains.
Metadata
Metadata
Assignees
Labels
No labels