yes kogge-stone towards 1 direction is about ~20 instructions long but at least it's branchless and the usual "for (uint64_ t b = ...; b; b &= b - 1)" it's not an easily predictable branch. measuring is the only answer.R. Tomasi wrote: ↑Fri Sep 10, 2021 9:02 pmInteresting idea. Kogge-Stone isn't completely free, either. I guess you would have to implement it and measure how that fits with the rest of your engine/movegenerator design.tcusr wrote: ↑Fri Sep 10, 2021 7:59 pmwhat if you generate the opponents rooks/queens attacks with the kogge stone algorithm and & those attacks with the rook attacks from your king?Mergi wrote: ↑Fri Sep 10, 2021 6:14 pmYou will still run into the problem of 2 or more pieces blocking at the same time, meaning that none of them is actually pinned. So you still need to go through every single attacker individually, cast a ray towards the king, and check that there's only 1 piece blocking. Also the magic lookups are not exactly free either, there's quite a lot of (cache unfriendly) operations needed to get the correct bitboard.R. Tomasi wrote: ↑Fri Sep 10, 2021 1:01 pm Btw, I think you can speed that up a little, assuming you're using magic bitboards: use the king square and the opponent occupancy bitboard to perform a magic lookup, then & mask it with the occupancy bitboard of your own pieces. That will give you any of your pieces that are pinned to your king and have to be excluded from move generation.
With your method, you get to immediately exclude attackers that are behind each other on the same ray, whereas i still go through all of them, but that should be fairly rare.
if there are rooks/queens in this mask it means they are pinned and you can generate the moves for them separately, you wouldn't need "if (blockers & SquareToBB(origin_s))" anymore. you would need to do again for bishops/queens though
i also thought about using kogge-stone to generate legal king moves. in makeMove() you can calculate all the squares attacked by both sides and then your legalKingMoves is just one statement. return kingAttacks[sq] & ~attackedBy[otherSide] & ~us;
this attackedBy table may also become useful for your evaluation function. i may try this but i have other things to improve for now.