From a89572fb64fb3d9d6e64fa5a34ba3fb3e294956e Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Tue, 22 Oct 2024 00:52:01 +0200 Subject: [PATCH] Improve performance by 1% by eliminating pnr --- src/Game/Chess/Internal/QuadBitboard.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Game/Chess/Internal/QuadBitboard.hs b/src/Game/Chess/Internal/QuadBitboard.hs index a6cb0b3..3586e75 100644 --- a/src/Game/Chess/Internal/QuadBitboard.hs +++ b/src/Game/Chess/Internal/QuadBitboard.hs @@ -72,14 +72,13 @@ data QuadBitboard = QBB { black, pbq, nbk, rqk :: {-# UNPACK #-} !Word64 } instance NFData QuadBitboard -occupied, pnr, white, pawns, knights, bishops, rooks, queens, kings :: QuadBitboard -> Word64 +occupied, white, pawns, knights, bishops, rooks, queens, kings :: QuadBitboard -> Word64 occupied = liftA2 (.|.) pbq $ liftA2 (.|.) nbk rqk -pnr = liftA2 xor pbq $ liftA2 xor nbk rqk white = liftA2 xor occupied black -pawns = liftA2 (.&.) pnr pbq -knights = liftA2 (.&.) pnr nbk +pawns = liftA2 (.&.) pbq $ liftA2 (.&.) (complement . nbk) (complement . rqk) +knights = liftA2 (.&.) (complement . pbq) $ liftA2 (.&.) nbk (complement . rqk) bishops = liftA2 (.&.) pbq nbk -rooks = liftA2 (.&.) pnr rqk +rooks = liftA2 (.&.) (complement . pbq) $ liftA2 (.&.) (complement . nbk) rqk queens = liftA2 (.&.) pbq rqk kings = liftA2 (.&.) nbk rqk @@ -99,7 +98,6 @@ bRooks = liftA2 (.&.) rooks black bQueens = liftA2 (.&.) queens black bKings = liftA2 (.&.) kings black -{-# INLINE pnr #-} {-# INLINE occupied #-} {-# INLINE white #-} {-# INLINE pawns #-}