94 days ago · Life · hide · Fediverse post

While having a go at writing my own chess engine I came across a ridiculously beautiful bit twiddling trick… So, I’m on my second weekend of trying to write a chess engine from scratch, having been thoroughly nerd-sniped by Lichess and their generous hosting of the Chess Programming Wiki. I’ve come across the Most Ridiculously Cool bit twiddling trick that I’m fairly sure all the engines use. Certainly the Not Quite A Tutorial As Such But Very Close To It that I am working through has it (see rustic-chess.org - it’s excellent) and I bet they all do. It’s to do with the en passant rule in chess, and how you can quickly calculate the target square for that rule, given either an en passant capture or a pawn move that may allow en passant on the following move. The thing is, in chess engines, most moves involve a start square A and an end square B, so a piece starts on A and ends up at B. In en passant, however, there’s a third square involved - the square behind the pawn that moved two…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town