Closed lantonov closed 7 years ago
You should be able to give this a try if you know what all of the instructions around https://github.com/lantonov/asmFish/blob/master/asmFish/guts/Evaluate.asm#L1608 do. You will also want to define the symbols QueenSide and KingSide. If you are not able to to do this or it is too much trouble, I (or someone else) will have a version soon.
I would really try if I know the instructions but I don't, unfortunately. Reading, for example, for popcnt "return the count of number of bits set to 1" I don't understand what is the use of that count, etc. Removing code is easy for me. Problems start when I have to add code.
My ponderings (please don't laugh):
popcnt r9, qword[rbp+Pos.typeBB+8*Pawn], rcx; popcnt counts the number of pawns somehow, qword[rbp+Pos.typeBB+8*Pawn] looks like number of pawns, this is stored in r9, no idea what individual terms in brackets mean
movzx edx, byte[rdi+PawnEntry.asymmetry]; this is the term with asymmetry, written in edx
lea edx, [rdx+r9-15]; this adds asymmetry + pawns - 15, no idea what is rdx ?
shl edx, 3; this shifts edx 3 places to the left, probably multiplies edx (the whole sum) by 8
lea r9d, [rdx+4*r9]; this multiplies the thing stored in r9 (pawns) by four and adds it to 8*(asy+pawns-15) in r9d
; r9d = 8*(asy+pawns-15)+4*pawns
movsx r10d, si; moves score from esi (si?) to r10d
In SF, we have 8 (asymmetry + kingDistance - 15) + 12 pawns; So, this must not be pawns, but kingDistance. And it is not 4 pawns but 12 pawns. Confusion and panic :(
popcnt "return the count of number of bits set to 1" I don't understand what is the use of that count
Well, you do understand what's a bitboard? It's a 64-bit (for chess) value, each bit corresponds to a square on the board. Example: A pawn bitboard has a bit set to 1 if a pawn is on the corresponding square, to 0 otherwise. But I'm not sure if you have a pawn bitboard or white pawn bitboard, or black pawn bitboard there.
So Pos.typeBB is the bitboard, something like 0000000000000100000000000000000001000001000001000000000000000000
Making analogy with other bracketed terms after perusing the code, in
qword[rbp+Pos.typeBB+8*Pawn]
is quadword (64 bits) somehow formed by adding rbp (the address of the bitboard) + Pos.typeBB (the bitboard itself; the 0s and 1s above) + 8 Pawn (this is probably a value that indicates the type of the bitboard). 8 Pawn is probably all pawns. I see in the code things like
mov rax, qword[rbp+Pos.typeBB+8*Black]
and rax, qword[rbp+Pos.typeBB+8*King]
which is probably the bitboard for the Black King (logical and)
is quadword (64 bits) somehow formed by adding rbp (the address of the bitboard) + Pos.typeBB (the bitboard itself; the 0s and 1s above) + 8 * Pawn (this is probably a value that indicates the type of the bitboard).
No. IIRC, brackets denote value at memory address inside the brackets. So, I guess, rbp
points to some structure, Pos.typeBB
is the offset of bitboard array inside the structure, 8*Pawn
is the offset from the beginning of the array (the 8 is the size of bitboard in bytes), and qword[rbp+Pos.typeBB+8*Pawn]
would be the actual bitboard.
Could be. In any case, it's beyond me. Maybe I can understand something with examples. It's very foggy to me now.
In SF, we have 8 (asymmetry + kingDistance - 15) + 12 pawns; So, this must not be pawns, but kingDistance. And it is not 4 pawns but 12 pawns. Confusion and panic :(
Please switch panic OFF and consider that you can represent the above as 8 * (asymmetry + pawns - 15) + 4 * pawns + 8 * kingDistance
Thanks, this is certainly comforting to know. Now that the operations are almost clear, we reach to the defining part:
const Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB;
const Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB;
and
bool bothFlanks = (pos.pieces(PAWN) & QueenSide) && (pos.pieces(PAWN) & KingSide);
By analogy with others, I guess that the first 2 would be:
QueenSide equ (FileABB or FileBBB or FileCBB or FileDBB)
KingSide equ (FileEBB or FileFBB or FileGBB or FileHBB)
pos.pieces(PAWN)
is qword[rbp+Pos.typeBB+8*Pawn]
(?)
you will find the latest changes on my fork. However, I don't like this whole stretch of code so I will probably clean in up (make it faster) soon.
Note that there is a branch in the code to handle the bool 'bothFlanks' and yes to pos.pieces(PAWN) is qword[rbp+Pos.typeBB+8*Pawn]
Thanks, committed to master and executables ready.
Need help with the patch "Keep pawns on both flanks" by snicolet