filter useless moves

This commit is contained in:
2026-05-16 12:14:09 -07:00
parent 4383228aad
commit ae591a6ee1
+13 -1
View File
@@ -224,7 +224,19 @@ fn main() -> Result<(), std::io::Error> {
}
}
SessionInstruction::Auto => {
if let Some(instruction) = session.possible_instructions().next() {
fn useless_moves(instruction: &KlondikeInstruction) -> bool {
// foundation -> foundation is a useless move
!matches!(
instruction,
KlondikeInstruction::DstFoundation(DstFoundation {
src: KlondikePile::Foundation(_),
..
})
)
}
if let Some(instruction) =
session.possible_instructions().filter(useless_moves).next()
{
session.process_instruction(instruction);
} else {
println!("No valid moves!");