From 6eb184c6ae9f1f27fde81f633100becdb508690d Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Thu, 22 Jul 2021 20:08:43 +0200 Subject: [PATCH] Add missing move checks --- src/world.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/world.rs b/src/world.rs index 3122c05..59f46d5 100644 --- a/src/world.rs +++ b/src/world.rs @@ -102,7 +102,10 @@ impl ActualWorld { match mv { Move::Noop => {} Move::TryTag(other_id) => { - // FIXME check distance + let my_pos = self.state.agent_positions.get(&id).unwrap(); + let other_pos = self.state.agent_positions.get(&other_id).unwrap(); + assert!((my_pos.x - other_pos.x).abs() <= 1); + assert!((my_pos.y - other_pos.y).abs() <= 1); assert_eq!(self.state.tagged, id); assert_ne!(self.state.tagged_by, Some(*other_id)); assert!( @@ -111,7 +114,8 @@ impl ActualWorld { ); } Move::TryMove(dir) => { - // FIXME check speed + assert!(dir.x.abs() <= 1); + assert!(dir.y.abs() <= 1); let pos = self.state.agent_positions.get(&id).unwrap(); let size = &self.size; assert!(pos.x + dir.x > 0);