|
@ -87,6 +87,7 @@ impl ActualWorld { |
|
|
self.check_move(id, &mv);
|
|
|
self.check_move(id, &mv);
|
|
|
}
|
|
|
}
|
|
|
let mut new_pos = None;
|
|
|
let mut new_pos = None;
|
|
|
|
|
|
let pos = self.state.agent_positions.get(&id).unwrap();
|
|
|
match mv {
|
|
|
match mv {
|
|
|
Move::Noop => {}
|
|
|
Move::Noop => {}
|
|
|
Move::TryTag(other_id) => {
|
|
|
Move::TryTag(other_id) => {
|
|
@ -94,14 +95,12 @@ impl ActualWorld { |
|
|
new_state.tagged_by = Some(id);
|
|
|
new_state.tagged_by = Some(id);
|
|
|
}
|
|
|
}
|
|
|
Move::TryMove(dir) => {
|
|
|
Move::TryMove(dir) => {
|
|
|
let pos = self.state.agent_positions.get(&id).unwrap();
|
|
|
|
|
|
new_pos = Some((pos.x + dir.x, pos.y + dir.y).into());
|
|
|
new_pos = Some((pos.x + dir.x, pos.y + dir.y).into());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
new_state.agent_positions.insert(
|
|
|
|
|
|
id,
|
|
|
|
|
|
new_pos.unwrap_or_else(|| self.state.agent_positions.remove(&id).unwrap()),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
new_state
|
|
|
|
|
|
.agent_positions
|
|
|
|
|
|
.insert(id, new_pos.unwrap_or_else(|| pos.clone()));
|
|
|
}
|
|
|
}
|
|
|
self.state = new_state;
|
|
|
self.state = new_state;
|
|
|
}
|
|
|
}
|
|
|