A simple actor-based simulation of tag, implemented in rust.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
544 B

3 years ago
  1. pub type Distance = isize;
  2. pub struct Position {
  3. pub x: Distance,
  4. pub y: Distance,
  5. }
  6. pub struct Direction {
  7. pub x: Distance,
  8. pub y: Distance,
  9. }
  10. pub type AgentId = usize;
  11. pub struct WorldView {
  12. pub self_tagged: bool,
  13. pub bounds_distance: (Distance, Distance, Distance, Distance),
  14. pub other_agents: Vec<(Direction, AgentId)>,
  15. }
  16. pub enum Move {
  17. Noop, // Why not an Option?
  18. TryTag(AgentId),
  19. TryMove(Direction),
  20. }
  21. pub trait Agent {
  22. fn next_move(&self, view: WorldView) -> Move;
  23. fn get_tagged(&mut self, by: AgentId);
  24. }