parent
d69b24dfd8
commit
2e0dbc958b
@ -0,0 +1,32 @@ |
|||||||
|
use antf::lib::screen::init_screen; |
||||||
|
use antf::lib::point::Point; |
||||||
|
use antf::lib::ai::AIGoal; |
||||||
|
use antf::lib::world::{World, simulate, render}; |
||||||
|
use antf::lib::entity::{Entities, Ant}; |
||||||
|
|
||||||
|
use ncurses::*; |
||||||
|
use std::thread::sleep; |
||||||
|
use std::time; |
||||||
|
|
||||||
|
#[test] |
||||||
|
fn test_astar() { |
||||||
|
let mut board = init_screen();
|
||||||
|
let mut world = World::new(); |
||||||
|
|
||||||
|
let mut entities = Entities::new(); |
||||||
|
let id = entities.add_ant(0,0); |
||||||
|
|
||||||
|
let a = entities.data.get_mut(&id).unwrap(); |
||||||
|
let ant: &mut Ant = a.downcast_mut::<Ant>().unwrap();
|
||||||
|
ant.goal = AIGoal::Reach(Point(10,10)); |
||||||
|
|
||||||
|
for _ in 0..60 { |
||||||
|
// TODO: add way to break out of the loop by hitting a random key
|
||||||
|
simulate(&mut entities, &mut world, &mut board); |
||||||
|
render(&entities, &world, &board); |
||||||
|
sleep(time::Duration::from_millis(100)); |
||||||
|
refresh(); |
||||||
|
} |
||||||
|
endwin(); |
||||||
|
} |
||||||
|
|
Loading…
Reference in new issue