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.

28 lines
512 B

3 years ago
3 years ago
3 years ago
  1. use gntag::{draw_world, get_view, get_world, DefaultView};
  2. fn main() {
  3. let view = get_view();
  4. loop {
  5. run_simulation(&view);
  6. }
  7. }
  8. fn run_simulation(view: &DefaultView) {
  9. let (width, height) = (*view.lock().unwrap())
  10. .as_mut()
  11. .unwrap()
  12. .content_size()
  13. .unwrap();
  14. let mut world = get_world(width, height, 10, true);
  15. let mut gen = 0;
  16. loop {
  17. let resized = draw_world(&world, gen, view).unwrap();
  18. if resized {
  19. return;
  20. };
  21. world.do_step();
  22. gen += 1;
  23. }
  24. }