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))
38 float h = fabs(a.x - b.x);
40 h *= pathlib_gridsize;
46 This heuristic consider both stright and disagonal moves
47 to have teh same cost.
49 float pathlib_h_diagonal(vector a,vector b)
51 //h(n) = D * max(abs(n.x-goal.x), abs(n.y-goal.y))
53 float hx = fabs(a.x - b.x);
54 float hy = fabs(a.y - b.y);
55 float h = pathlib_movecost * max(hx,hy);
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)
77 h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
78 h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
79 h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
82 float hx = fabs(a.x - b.x);
83 float hy = fabs(a.y - b.y);
85 float h_diag = min(hx,hy);
86 float h_str = hx + hy;
88 float h = pathlib_movecost_diag * h_diag;
89 h += pathlib_movecost * (h_str - 2 * h_diag);
95 This heuristic consider both stright and disagonal moves,
96 But has a separate cost for diagonal moves.
98 float pathlib_h_diagonal2sdp(vector preprev,vector prev,vector point,vector end)
100 //h_diagonal(n) = min(abs(n.x-goal.x), abs(n.y-goal.y))
101 //h_straight(n) = (abs(n.x-goal.x) + abs(n.y-goal.y))
102 //h(n) = D2 * h_diagonal(n) + D * (h_straight(n) - 2*h_diagonal(n)))
104 float hx = fabs(point.x - end.x);
105 float hy = fabs(point.y - end.y);
106 float hz = fabs(point.z - end.z);
108 float h_diag = min3(hx,hy,hz);
109 float h_str = hx + hy + hz;
111 float h = pathlib_movecost_diag * h_diag;
112 h += pathlib_movecost * (h_str - 2 * h_diag);
114 vector d1 = normalize(preprev - point);
115 vector d2 = normalize(prev - point);
116 float m = vlen(d1-d2);
122 float pathlib_h_diagonal3(vector a,vector b)
124 float hx = fabs(a.x - b.x);
125 float hy = fabs(a.y - b.y);
126 float hz = fabs(a.z - b.z);
128 float h_diag = min3(hx,hy,hz);
129 float h_str = hx + hy + hz;
131 float h = pathlib_movecost_diag * h_diag;
132 h += pathlib_movecost * (h_str - 2 * h_diag);