semi working dig routine

This commit is contained in:
2024-01-04 12:12:50 -07:00
parent ded96cc4b9
commit 6508b51fb3
6 changed files with 179 additions and 78 deletions
+19 -18
View File
@@ -1,8 +1,8 @@
use antf::lib::screen::{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, Food, FoodGenerator};
use antf::lib::entity::{Ant, Entities, Food, FoodGenerator};
use antf::lib::point::Point;
use antf::lib::screen::{init_screen, Screen};
use antf::lib::world::{render, simulate, World};
use ncurses::*;
use std::thread::sleep;
@@ -12,20 +12,21 @@ use std::time;
#[test]
fn test_reach_astar() {
let mut board = init_screen();//Screen::new(40,40);
let mut board = init_screen(); //Screen::new(40,40);
let mut world = World::new();
world.clear(Point(0, 0));
let mut entities = Entities::new();
let a = Ant::new(0,0);
let a = Ant::new(0, 0);
let id = entities.add_entity(&a);
let a = entities.data.get_mut(&id).unwrap();
let ant: &mut Ant = a.downcast_mut::<Ant>().unwrap();
ant.plan.push(AIGoal::Reach(Point(10,10)));
ant.plan.push(AIGoal::Reach(Point(-10,-10)));
ant.plan.push(AIGoal::Reach(Point(10,-10)));
ant.plan.push(AIGoal::Reach(Point(-10,10)));
let ant: &mut Ant = a.downcast_mut::<Ant>().unwrap();
ant.plan.push(AIGoal::Reach(Point(0, 0)));
ant.plan.push(AIGoal::Reach(Point(20, 20)));
ant.plan.push(AIGoal::Reach(Point(0, 0)));
ant.plan.push(AIGoal::Reach(Point(20, 20)));
// craps out... need to make sure unwrap() is safe
for _ in 0..420 {
@@ -41,21 +42,21 @@ fn test_reach_astar() {
/*#[test]
fn test_drag() {
let mut board = init_screen();
let mut board = init_screen();
let mut world = World::new();
let mut entities = Entities::new();
let f = Food::new(10,10);
let a = Ant::new(0,0);
let fid = entities.add_entity(&f);
let id = entities.add_entity(&a);
let a = entities.data.get_mut(&id).unwrap();
let ant: &mut Ant = a.downcast_mut::<Ant>().unwrap();
//ant.goal =
//ant.goal =
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);
@@ -64,5 +65,5 @@ fn test_drag() {
refresh();
}
clear();
endwin();
endwin();
}*/