void Alien::update_logic(){//Update Alien move int prey_x; int prey_y; if(!find(prey_x,prey_y,x,y)){ move(goRandom()); } else{ move(goTo(prey_x,prey_y)); } }
int main(int argc, char* argv[]) { Map map; Car cars[3] = {NULL, NULL, NULL}; int x, y, i, rounds = 0, needPathfinding = 0, firstLoop = 1; List path; Position position; Vector acc; int fuel; srand(time(NULL)); freopen("pshr4log.txt", "w+", stderr); // freopen("map.txt", "r", stdin); LOGINFO("Starting"); initGC(); map = Map_load(stdin); LOGINFO("Map loaded"); while(!feof(stdin)) { LOGINFO1I("===== Round number %d =====", rounds); for(i = 0; i < 3; i++) { fscanf(stdin, "%d %d", &x, &y); LOGINFO3I("Car number %i, position : %d %d", i, x, y); if(cars[i] == NULL) cars[i] = Car_new(x, y); else Car_updatePosition(cars[i], x, y); if(Car_updateArrivedStatus(cars[i], map)) { recomputeDistances(map, cars); LOGINFO("I see you've arrived, let me see where I can park now..."); needPathfinding = 1; } } if(firstLoop) { firstLoop = 0; path = doPathfinding(map, cars); List_tail(path); List_prev(path); } position = List_getCurrent(path); for(i = 1; i < 3; i++) { if(Position_equal(position, Car_getPosition(cars[i]))) { needPathfinding = 1; LOGINFO("YOU TOOK MY SPOT JERK"); } } if(needPathfinding) { freePath(path); path = doPathfinding(map, cars); List_tail(path); List_prev(path); needPathfinding = 0; position = List_getCurrent(path); } if(position == NULL) { goRandom(); } else { LOGINFO2I("Going to %d %d", position->x, position->y); acc = Car_getAccelerationToReach(cars[0], position); go(acc->x, acc->y); if(Vector_squaredLength(acc) > 2) { Car_useBoost(cars[0]); LOGINFO("Using a boost"); } Vector_delete(acc); } List_prev(path); rounds++; } LOGINFO("End"); freePath(path); for(i = 0; i < 3; i++) { Car_delete(cars[i]); } Map_delete(map); freeGC(); return 0; }
void Human::update_logic(){ move(goRandom()); // move(direction_t::UP); }