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.
42 lines
1.0 KiB
42 lines
1.0 KiB
use gntag::agent::{Agent, SimpleAgent};
|
|
use gntag::view::TerminalView;
|
|
use gntag::world::ActualWorld;
|
|
|
|
fn main() {
|
|
let mut view = TerminalView::try_new().unwrap();
|
|
loop {
|
|
let (width, height) = view.content_size().unwrap();
|
|
let mut agents: Vec<(_, Box<dyn Agent>)> = vec![];
|
|
for x in (0..width).step_by(10) {
|
|
for y in (0..height).step_by(10) {
|
|
agents.push(((x, y).into(), Box::new(SimpleAgent)));
|
|
}
|
|
}
|
|
let mut world = ActualWorld::new((width, height).into(), agents);
|
|
|
|
let mut gen = 0;
|
|
loop {
|
|
let resized = view
|
|
.draw(
|
|
gen,
|
|
world
|
|
.agent_positions
|
|
.get(&world.tagged)
|
|
.map(|pos| (pos.x, pos.y))
|
|
.unwrap(),
|
|
world
|
|
.agent_positions
|
|
.iter()
|
|
.map(|(_id, pos)| (pos.x, pos.y))
|
|
.collect::<Vec<_>>()
|
|
.as_ref(),
|
|
)
|
|
.unwrap();
|
|
if resized {
|
|
break;
|
|
};
|
|
world.do_step();
|
|
gen += 1;
|
|
}
|
|
}
|
|
}
|