diff --git a/src/games/gonnect.rs b/src/games/gonnect.rs index 7a4376e..42b193b 100644 --- a/src/games/gonnect.rs +++ b/src/games/gonnect.rs @@ -38,6 +38,7 @@ pub struct Move(u8, u64); impl Move { const SWAP: Move = Move(0xff, 0); + const NO_MOVE: Move = Move(0xfe, 0); } #[derive(Clone, Copy, Serialize, Debug)] @@ -121,7 +122,9 @@ impl State { #[inline] fn apply(&mut self, action: &Move) -> Self { - if *action == Move::SWAP { + if *action == Move::NO_MOVE { + self.winner = true; + } else if *action == Move::SWAP { swap(&mut self.black, &mut self.white); self.can_swap = false; } else { @@ -178,6 +181,9 @@ impl Game for Gonnect { actions.push(Move(index as u8, will_capture.get_raw())) } } + if actions.is_empty() { + actions.push(Move::NO_MOVE); + } } fn is_terminal(state: &State) -> bool {