46 |
checker.x = x + x_coords[i]; |
checker.x = x + x_coords[i]; |
47 |
checker.y = y + y_coords[i]; |
checker.y = y + y_coords[i]; |
48 |
|
|
49 |
if( map->IsValid(checker.x, checker.y) == 1 ) { // is valid |
if( themap->IsValid(checker.x, checker.y) == 1 ) { // is valid |
50 |
temp = map->GetOccu(checker.x, checker.y); // get occupant if any |
temp = themap->GetOccu(checker.x, checker.y); // get occupant if any |
51 |
if ( (map->GetObst(checker.x, checker.y) != 1) && // is not a blocked tile |
if ( (themap->GetObst(checker.x, checker.y) != 1) && // is not a blocked tile |
52 |
!((parent_x == checker.x) && (parent_y == checker.y) ) // isn't where we just came from |
!((parent_x == checker.x) && (parent_y == checker.y) ) // isn't where we just came from |
53 |
) { |
) { |
54 |
if (temp == NULL || checker.IsGoal( *(astarsearch->GetSolutionEnd()) ) == 1) { // if not already occupied -OR- it's the goal state. |
if (temp == NULL || checker.IsGoal( *(astarsearch->GetSolutionEnd()) ) == 1) { // if not already occupied -OR- it's the goal state. |
83 |
for (int j=-rad; j <= rad; j++) { |
for (int j=-rad; j <= rad; j++) { |
84 |
if (j==0 && i==0) {continue;} // don't check self |
if (j==0 && i==0) {continue;} // don't check self |
85 |
//--------\/--------- |
//--------\/--------- |
86 |
if( map->IsValid(successor.x + i, successor.y + j) ) { // is valid |
if( themap->IsValid(successor.x + i, successor.y + j) ) { // is valid |
87 |
// TODO: check visor for visibilty in this tile |
// TODO: check visor for visibilty in this tile |
88 |
temp = map->GetOccu(successor.x + i, successor.y + j); // get occupant if any |
temp = themap->GetOccu(successor.x + i, successor.y + j); // get occupant if any |
89 |
if (temp != NULL) { // isn't already occupied. |
if (temp != NULL) { // isn't already occupied. |
90 |
if (temp->GetAlign() != pod->GetAlign()) { // if not on our team |
if (temp->GetAlign() != pod->GetAlign()) { // if not on our team |
91 |
enemy_cost += (10 * pod->GetAvoid());// TODO: avoidence amplified by map size. otherwise, H takes too much over G on larger maps |
enemy_cost += (10 * pod->GetAvoid());// TODO: avoidence amplified by map size. otherwise, H takes too much over G on larger maps |
99 |
} |
} |
100 |
|
|
101 |
// Road Quality - we like roads |
// Road Quality - we like roads |
102 |
int road_q = map->GetRoadQ(successor.x, successor.y); |
int road_q = themap->GetRoadQ(successor.x, successor.y); |
103 |
|
|
104 |
return ( (road_q / 2) + enemy_cost ); |
return ( (road_q / 2) + enemy_cost ); |
105 |
} |
} |