Underpromotion?

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Re: Underpromotion?

Post by hgm »

Well, tests with 100% predictable branches are pretty cheap. And you would only do the test in the move generator after having ascertained that a Pawn move is a promotion, which basially means it is in code that is executed extremely rarely. But if you want to allow people to disable promotion to, say, Bishop without any overhead whatsoever (compared to searching all promotions) you could implement it by generating a duplicate promotion to Queen for it. The resulting hash hit then would kill it. Which is not as efficient as already killing it in the move generator,but still far better than actually searching it.

I cannot speak for your engine, but in Spartacus I could easily do it that way: promotions are encoded through off-board to-squares, and that to-square is than used in the special-moves part of MakeMove as a table index to retrieve the actual piece type and other necessary information for the piece. I could simply initialize that table with 4 times the entries for Queen to suppress all under-promotion.

I use a similar trick for testing e.p. rights in Berolina Chess. In orthodox Chess you always have to test on both sides after a double push for presence of enemy Pawns. But after e2-c4 e.p. capture would only be possible by a Pawn on d4 (d4xd3). So I put the squares that have to be tested in a table, and for an e2-c4 double-push I just fill the table so that it tests d4 twice (while for a2-c4 it would have tested b4 twice). That way the MakeMove code can always do two tests, which made more sense than first testing how often I should test, as this causes no overhead in orthodox Chess now.