3 float pathlib_g_static(entity parent,vector to, float static_cost)
5 return parent.pathlib_node_g + static_cost;
8 float pathlib_g_static_water(entity parent,vector to, float static_cost)
11 return parent.pathlib_node_g + static_cost * pathlib_movecost_waterfactor;
13 return parent.pathlib_node_g + static_cost;
16 float pathlib_g_euclidean(entity parent,vector to, float static_cost)
18 return parent.pathlib_node_g + vlen(parent.origin - to);
21 float pathlib_g_euclidean_water(entity parent,vector to, float static_cost)
24 return parent.pathlib_node_g + vlen(parent.origin - to) * pathlib_movecost_waterfactor;
26 return parent.pathlib_node_g + vlen(parent.origin - to);
31 Manhattan Menas we expect to move up,down left or right
32 No diagonal moves espected. (like moving bewteen city blocks)
34 float pathlib_h_manhattan(vector a,vector b)
36 //h(n) = D * (abs(n.x-goal.x) + abs(n.y-goal.y))
41 h *= pathlib_gridsize;
47 This heuristic consider both stright and disagonal moves
48 to have teh same cost.
50 float pathlib_h_diagonal(vector a,vector b)
52 //h(n) = D * max(abs(n.x-goal.x), abs(n.y-goal.y))
57 h = pathlib_movecost * max(x,y);
63 This heuristic only considers the stright line distance.
64 Will usualy mean a lower H then G meaning A* Will speand more
67 float pathlib_h_euclidean(vector a,vector b)
73 This heuristic consider both stright and disagonal moves,
74 But has a separate cost for diagonal moves.
76 float pathlib_h_diagonal2(vector a,vector b)
78 float h_diag,h_str,h,x,y;
81 h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
82 h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
83 h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
92 h = pathlib_movecost_diag * h_diag;
93 h += pathlib_movecost * (h_str - 2 * h_diag);
99 This heuristic consider both stright and disagonal moves,
100 But has a separate cost for diagonal moves.
102 float pathlib_h_diagonal2sdp(vector preprev,vector prev,vector point,vector end)
104 float h_diag,h_str,h,x,y,z;
106 //h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
107 //h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
108 //h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
110 x = fabs(point.x - end.x);
111 y = fabs(point.y - end.y);
112 z = fabs(point.z - end.z);
117 h = pathlib_movecost_diag * h_diag;
118 h += pathlib_movecost * (h_str - 2 * h_diag);
123 d1 = normalize(preprev - point);
124 d2 = normalize(prev - point);
131 float pathlib_h_diagonal3(vector a,vector b)
133 float h_diag,h_str,h,x,y,z;
142 h = pathlib_movecost_diag * h_diag;
143 h += pathlib_movecost * (h_str - 2 * h_diag);