1 float pathlib_g_static(entity parent,vector to, float static_cost)
\r
3 return parent.pathlib_node_g + static_cost;
\r
6 float pathlib_g_static_water(entity parent,vector to, float static_cost)
\r
9 return parent.pathlib_node_g + static_cost * pathlib_movecost_waterfactor;
\r
11 return parent.pathlib_node_g + static_cost;
\r
14 float pathlib_g_euclidean(entity parent,vector to, float static_cost)
\r
16 return parent.pathlib_node_g + vlen(parent.origin - to);
\r
19 float pathlib_g_euclidean_water(entity parent,vector to, float static_cost)
\r
22 return parent.pathlib_node_g + vlen(parent.origin - to) * pathlib_movecost_waterfactor;
\r
24 return parent.pathlib_node_g + vlen(parent.origin - to);
\r
29 Manhattan Menas we expect to move up,down left or right
\r
30 No diagonal moves espected. (like moving bewteen city blocks)
\r
32 float pathlib_h_manhattan(vector a,vector b)
\r
34 //h(n) = D * (abs(n.x-goal.x) + abs(n.y-goal.y))
\r
37 h = fabs(a_x - b_x);
\r
38 h += fabs(a_y - b_y);
\r
39 h *= pathlib_gridsize;
\r
45 This heuristic consider both stright and disagonal moves
\r
46 to have teh same cost.
\r
48 float pathlib_h_diagonal(vector a,vector b)
\r
50 //h(n) = D * max(abs(n.x-goal.x), abs(n.y-goal.y))
\r
53 x = fabs(a_x - b_x);
\r
54 y = fabs(a_y - b_y);
\r
55 h = pathlib_movecost * max(x,y);
\r
61 This heuristic only considers the stright line distance.
\r
62 Will usualy mean a lower H then G meaning A* Will speand more
\r
65 float pathlib_h_euclidean(vector a,vector b)
\r
71 This heuristic consider both stright and disagonal moves,
\r
72 But has a separate cost for diagonal moves.
\r
74 float pathlib_h_diagonal2(vector a,vector b)
\r
76 float h_diag,h_str,h,x,y;
\r
79 h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
\r
80 h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
\r
81 h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
\r
84 x = fabs(a_x - b_x);
\r
85 y = fabs(a_y - b_y);
\r
90 h = pathlib_movecost_diag * h_diag;
\r
91 h += pathlib_movecost * (h_str - 2 * h_diag);
\r
97 This heuristic consider both stright and disagonal moves,
\r
98 But has a separate cost for diagonal moves.
\r
100 float pathlib_h_diagonal2sdp(vector preprev,vector prev,vector point,vector end)
\r
102 float h_diag,h_str,h,x,y,z;
\r
104 //h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
\r
105 //h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
\r
106 //h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
\r
108 x = fabs(point_x - end_x);
\r
109 y = fabs(point_y - end_y);
\r
110 z = fabs(point_z - end_z);
\r
112 h_diag = min3(x,y,z);
\r
115 h = pathlib_movecost_diag * h_diag;
\r
116 h += pathlib_movecost * (h_str - 2 * h_diag);
\r
121 d1 = normalize(preprev - point);
\r
122 d2 = normalize(prev - point);
\r
129 float pathlib_h_diagonal3(vector a,vector b)
\r
131 float h_diag,h_str,h,x,y,z;
\r
133 x = fabs(a_x - b_x);
\r
134 y = fabs(a_y - b_y);
\r
135 z = fabs(a_z - b_z);
\r
137 h_diag = min3(x,y,z);
\r
140 h = pathlib_movecost_diag * h_diag;
\r
141 h += pathlib_movecost * (h_str - 2 * h_diag);
\r