4 float pathlib_g_static(entity parent,vector to, float static_cost)
6 return parent.pathlib_node_g + static_cost;
9 float pathlib_g_static_water(entity parent,vector to, float static_cost)
12 return parent.pathlib_node_g + static_cost * pathlib_movecost_waterfactor;
14 return parent.pathlib_node_g + static_cost;
17 float pathlib_g_euclidean(entity parent,vector to, float static_cost)
19 return parent.pathlib_node_g + vlen(parent.origin - to);
22 float pathlib_g_euclidean_water(entity parent,vector to, float static_cost)
25 return parent.pathlib_node_g + vlen(parent.origin - to) * pathlib_movecost_waterfactor;
27 return parent.pathlib_node_g + vlen(parent.origin - to);
32 Manhattan Menas we expect to move up,down left or right
33 No diagonal moves espected. (like moving bewteen city blocks)
35 float pathlib_h_manhattan(vector a,vector b)
37 //h(n) = D * (abs(n.x-goal.x) + abs(n.y-goal.y))
42 h *= pathlib_gridsize;
48 This heuristic consider both stright and disagonal moves
49 to have teh same cost.
51 float pathlib_h_diagonal(vector a,vector b)
53 //h(n) = D * max(abs(n.x-goal.x), abs(n.y-goal.y))
58 h = pathlib_movecost * max(x,y);
64 This heuristic only considers the stright line distance.
65 Will usualy mean a lower H then G meaning A* Will speand more
68 float pathlib_h_euclidean(vector a,vector b)
74 This heuristic consider both stright and disagonal moves,
75 But has a separate cost for diagonal moves.
77 float pathlib_h_diagonal2(vector a,vector b)
79 float h_diag,h_str,h,x,y;
82 h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
83 h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
84 h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
93 h = pathlib_movecost_diag * h_diag;
94 h += pathlib_movecost * (h_str - 2 * h_diag);
100 This heuristic consider both stright and disagonal moves,
101 But has a separate cost for diagonal moves.
103 float pathlib_h_diagonal2sdp(vector preprev,vector prev,vector point,vector end)
105 float h_diag,h_str,h,x,y,z;
107 //h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
108 //h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
109 //h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
111 x = fabs(point.x - end.x);
112 y = fabs(point.y - end.y);
113 z = fabs(point.z - end.z);
115 h_diag = min3(x,y,z);
118 h = pathlib_movecost_diag * h_diag;
119 h += pathlib_movecost * (h_str - 2 * h_diag);
124 d1 = normalize(preprev - point);
125 d2 = normalize(prev - point);
132 float pathlib_h_diagonal3(vector a,vector b)
134 float h_diag,h_str,h,x,y,z;
140 h_diag = min3(x,y,z);
143 h = pathlib_movecost_diag * h_diag;
144 h += pathlib_movecost * (h_str - 2 * h_diag);