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