|
|
@ -1,5 +1,5 @@ |
|
|
|
use gntag::agent::{Agent, SimpleAgent};
|
|
|
|
use gntag::view::TerminalView;
|
|
|
|
use gntag::view::{Backend, TerminalView};
|
|
|
|
use gntag::world::ActualWorld;
|
|
|
|
use std::io;
|
|
|
|
use std::io::Read;
|
|
|
@ -9,6 +9,8 @@ use std::thread; |
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let view = Arc::new(Mutex::new(Some(TerminalView::try_new().unwrap())));
|
|
|
|
|
|
|
|
// Exit on q, ESC and Ctrl-C and reset terminal
|
|
|
|
let view2 = view.clone();
|
|
|
|
thread::spawn(move || {
|
|
|
|
let stdin = io::stdin();
|
|
|
@ -22,7 +24,13 @@ fn main() { |
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
loop {
|
|
|
|
run_simulation(&view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn run_simulation(view: &Arc<Mutex<Option<TerminalView<impl Backend>>>>) {
|
|
|
|
let (width, height) = (*view.lock().unwrap())
|
|
|
|
.as_mut()
|
|
|
|
.unwrap()
|
|
|
@ -59,11 +67,9 @@ fn main() { |
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
if resized {
|
|
|
|
break;
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
world.do_step();
|
|
|
|
gen += 1;
|
|
|
|
//std::thread::sleep(std::time::Duration::from_millis(500));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|