From ae591a6ee1b0001d9dcb80481a08b0c077f9028f Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Sat, 16 May 2026 12:14:09 -0700 Subject: [PATCH] filter useless moves --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3d304ff..c223bce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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!");