niklasf/shakmaty

detect insufficient material for Horde

Closed this issue · 6 comments

to check if a given side can still win. this is required to adjudicate positions when a player runs out of time

horde not done, yet

shakmaty/src/position.rs

Lines 1500 to 1502 in 4b75283

// TODO: Detect when the horde can not mate. Note that it does not have
// a king.
false

Can I help?

Yes, please :)

Whether or not the horde can mate is irrelevant; at least for this computation

shakmaty/src/position.rs

Lines 267 to 269 in 4b75283

fn is_insufficient_material(&self) -> bool {
self.has_insufficient_material(White) && self.has_insufficient_material(Black)
}

since even a lone king preserves winning chances for the side with the pieces. In other words, there can be no draw by insufficient material in this variant.

So what shall self.has_insufficient_material(White) return? Perhaps implementing the correct behaviour is not worth the trouble.

Correct, a Horde game can never end by is_insufficient_material. But Black could run out of time, in a position where self.has_insufficient_material(White) is true. Then the game should be drawn, not lost for Black. Current docs explain the meaning.

I agree that this will be a rare edge case.

Done a while ago via 6501b53 and follow-ups ❤️