34 |
|
|
35 |
MapSearchNode_Pod NewNode; |
MapSearchNode_Pod NewNode; |
36 |
|
|
37 |
|
|
38 |
// loop through each adjacent tile for elegibility - no diags |
// loop through each adjacent tile for elegibility - no diags |
39 |
int x_coords[] = {1,-1,0,0}; |
int x_coords[] = {1,-1,0,0}; |
40 |
int y_coords[] = {0,0,1,-1}; |
int y_coords[] = {0,0,1,-1}; |
41 |
Pod* temp; |
Pod* temp; |
42 |
for (int i=0; i < 3; i++) { |
MapSearchNode_Pod checker; |
43 |
if( map->IsValid(x + x_coords[i], y + y_coords[i]) == 1 ) { // is valid |
for (int i=0; i < 4; i++) { |
44 |
temp = map->GetOccu(x + x_coords[i], y + y_coords[i]); // get occupant if any |
|
45 |
if ( (map->GetObst(x + x_coords[i], y + y_coords[i]) != 1) && // is not a blocked tile |
// our sample "checker" node |
46 |
!((parent_x == x + x_coords[i]) && (parent_y == y + y_coords[i])) && // isn't where we just came from |
checker.x = x + x_coords[i]; |
47 |
temp == NULL // isn't already occupied. TODO: check visor for visibilty / stealth |
checker.y = y + y_coords[i]; |
48 |
|
|
49 |
|
if( map->IsValid(checker.x, checker.y) == 1 ) { // is valid |
50 |
|
temp = map->GetOccu(checker.x, checker.y); // get occupant if any |
51 |
|
if ( (map->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 |
53 |
) { |
) { |
54 |
NewNode = MapSearchNode_Pod( x + x_coords[i], y + y_coords[i] ); |
if (temp == NULL || checker.IsGoal( *(astarsearch->GetSolutionEnd()) ) == 1) { // if not already occupied -OR- it's the goal state. |
55 |
astarsearch->AddSuccessor( NewNode ); |
// we allow occupation-exception override here because the pod's Walk() is |
56 |
|
// programmed to stop before occupied tiles but still needs to be able to |
57 |
|
// set course for intercept, which obviously means the last tile is always occupied. |
58 |
|
// TODO: check visor for visibilty / stealth |
59 |
|
NewNode = MapSearchNode_Pod( checker.x, checker.y ); |
60 |
|
astarsearch->AddSuccessor( NewNode ); |
61 |
|
} |
62 |
} |
} |
63 |
} |
} |
64 |
} |
} |
65 |
|
|
66 |
return true; |
return true; |
67 |
} |
} |
68 |
|
|
88 |
temp = map->GetOccu(successor.x + i, successor.y + j); // get occupant if any |
temp = map->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 += .1 * 1000; // dummy numbers |
enemy_cost += (10 * pod->GetAvoid());// TODO: avoidence amplified by map size. otherwise, H takes too much over G on larger maps |
|
// TODO: amplified by avoidence |
|
|
// TODO: avoidence amplified by map size. otherwise, H takes too much over G on larger maps |
|
92 |
} |
} |
93 |
} |
} |
94 |
|
|
95 |
} |
} |
96 |
|
|
97 |
//--------/\--------- |
//--------/\--------- |
98 |
} |
} |
99 |
} |
} |