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.
47 lines
891 B
47 lines
891 B
use gntag::{get_view, get_world, DefaultView};
|
|
|
|
fn main() {
|
|
let view = get_view();
|
|
|
|
loop {
|
|
run_simulation(&view);
|
|
}
|
|
}
|
|
|
|
fn run_simulation(view: &DefaultView) {
|
|
let (width, height) = (*view.lock().unwrap())
|
|
.as_mut()
|
|
.unwrap()
|
|
.content_size()
|
|
.unwrap();
|
|
let mut world = get_world(width, height, 10, true);
|
|
|
|
let mut gen = 0;
|
|
loop {
|
|
let resized = (*view.lock().unwrap())
|
|
.as_mut()
|
|
.unwrap()
|
|
.draw(
|
|
gen,
|
|
world
|
|
.state
|
|
.agent_positions
|
|
.get(&world.state.tagged)
|
|
.map(|pos| (pos.x, pos.y))
|
|
.unwrap(),
|
|
world
|
|
.state
|
|
.agent_positions
|
|
.iter()
|
|
.map(|(_id, pos)| (pos.x, pos.y))
|
|
.collect::<Vec<_>>()
|
|
.as_ref(),
|
|
)
|
|
.unwrap();
|
|
if resized {
|
|
return;
|
|
};
|
|
world.do_step();
|
|
gen += 1;
|
|
}
|
|
}
|