I think it like this:

Moderator: Ras
I do not understand enough of how the operators and bits works to see why is like this, sorry.Sven wrote: ↑Fri Mar 26, 2021 12:53 pmYou can express 12 as 3*4 or as 3*(sqrt(64)/2) ...Luis Babboni wrote: ↑Fri Mar 26, 2021 12:39 pmYes, must be FileA!Sven wrote: ↑Fri Mar 26, 2021 11:25 amI would rename "File1" into "FileA" but that is a matter of taste.Luis Babboni wrote: ↑Fri Mar 26, 2021 3:28 am For white pawns left captures:
((((WhitePawns AND File1) XOR WhitePawns) shl 7) AND BlackPieces) give me the bitboard with all the "to"
More important, the expression above is wrong, it should be:
(((WhitePawns AND NOT FileA) shl 7) AND BlackPieces) give me the bitboard with all the "to"
All bits belonging to the A-file must be cleared before shifting, and also the additional XOR does not make sense, it would flip a lot of bits.
...
![]()
I still think my code is right, but your suggest is shorter (so better)!
EDIT: not sure if yours is shorter.
What is shorter:
BB1 AND BB2 XOR BB2
or
BB1 AND NOT BB2?
That is not my point.Luis Babboni wrote: ↑Fri Mar 26, 2021 1:02 pmI do not understand enough of how the operators and bits works to see why is like this, sorry.Sven wrote: ↑Fri Mar 26, 2021 12:53 pmYou can express 12 as 3*4 or as 3*(sqrt(64)/2) ...Luis Babboni wrote: ↑Fri Mar 26, 2021 12:39 pmYes, must be FileA!Sven wrote: ↑Fri Mar 26, 2021 11:25 amI would rename "File1" into "FileA" but that is a matter of taste.Luis Babboni wrote: ↑Fri Mar 26, 2021 3:28 am For white pawns left captures:
((((WhitePawns AND File1) XOR WhitePawns) shl 7) AND BlackPieces) give me the bitboard with all the "to"
More important, the expression above is wrong, it should be:
(((WhitePawns AND NOT FileA) shl 7) AND BlackPieces) give me the bitboard with all the "to"
All bits belonging to the A-file must be cleared before shifting, and also the additional XOR does not make sense, it would flip a lot of bits.
...
![]()
I still think my code is right, but your suggest is shorter (so better)!
EDIT: not sure if yours is shorter.
What is shorter:
BB1 AND BB2 XOR BB2
or
BB1 AND NOT BB2?
The NOT is faster than all others?
So is a matter of "sthetic"? (Not few thinking in a future understanding)
No, a matter of "straight forward thinking". Just don't wrap your head around how fast those bit operations are (and the difference is not that big). You are currently in a phase where you want to try to understand basic bitboard concepts. The basic concept of clearing some bits BB2 in a bitboard BB1 is simply expressed by "BB1 AND NOT BB2". The "NOT BB2" part ensures that the BB2 bits are cleared when AND-ing with it. Doing "(BB1 AND BB2) XOR BB1" is possible as well but why would you prefer obfuscation over clarity?Luis Babboni wrote: ↑Fri Mar 26, 2021 1:12 pmSo is a matter of "sthetic"? (Not few thinking in a future understanding)
I choiced the first just cause was the first I could find, no more.Sven wrote: ↑Fri Mar 26, 2021 1:49 pmNo, a matter of "straight forward thinking". Just don't wrap your head around how fast those bit operations are (and the difference is not that big). You are currently in a phase where you want to try to understand basic bitboard concepts. The basic concept of clearing some bits BB2 in a bitboard BB1 is simply expressed by "BB1 AND NOT BB2". The "NOT BB2" part ensures that the BB2 bits are cleared when AND-ing with it. Doing "(BB1 AND BB2) XOR BB1" is possible as well but why would you prefer obfuscation over clarity?Luis Babboni wrote: ↑Fri Mar 26, 2021 1:12 pmSo is a matter of "sthetic"? (Not few thinking in a future understanding)
On the other hand, having a precomputed table would introduce a memory load which is not fast at all.Luis Babboni wrote: ↑Fri Mar 26, 2021 1:07 pm Mmmmm, may be the NOT could be faster, use just one BB, but no matter that, I could have a NOTFilaA BB stored since the engine boot.![]()
I´m right?
Thanks!
Code: Select all
bb_a: 1011 0110
bb_b: 1100 0100
Code: Select all
bb_a: 1011 0110
AND
NOT bb_a: 0011 1011 (not bb_b is the reverse of bb_b above)
============================
result 0011 0010