Branchless make/unmake logic

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Branchless make/unmake logic

Post by hgm »

That makes it even worse, right? You will have to do a lot of register-to-register copying, shifting and masking to extract the field you want to XOR with.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Branchless make/unmake logic

Post by dangi12012 »

I think both of you are missing a nuance. Unmake is a function that is only needed if the state you are maintaining is big - similar to the many k element accumulator - and then the interface matters.

If the board itself is small enough you dont have to undo anything ever. In fact it will be slower. For example this code here proves this:

//"move" points to a list of compilationtime defined deltas when applied to any board can kill a piece, silent moves as well as setting enpassant or castling etc.
while(*move)
{
next = _mm256_xor_si256(prev, *move++)
//reverse board here for color agnostic chess
//Do whatever with next
}

In fact when movegeneration takes a generic T as a template parameter you can inject the T "MoveGen" into Alphabeta and remove movelists generally. For AB you dont pre-order the moves but pick which move to expand according to a policy like the silent eval if applicable on that board etc.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer