equal
deleted
inserted
replaced
136 |
136 |
137 /** Called by YAPF to calculate cost estimate. Calculates distance to the destination |
137 /** Called by YAPF to calculate cost estimate. Calculates distance to the destination |
138 * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ |
138 * adds it to the actual cost from origin and stores the sum to the Node::m_estimate */ |
139 inline bool PfCalcEstimate(Node& n) |
139 inline bool PfCalcEstimate(Node& n) |
140 { |
140 { |
141 int dx = abs(TileX(n.GetTile()) - TileX(m_destTile)); |
141 int dx = delta(TileX(n.GetTile()), TileX(m_destTile)); |
142 int dy = abs(TileY(n.GetTile()) - TileY(m_destTile)); |
142 int dy = delta(TileY(n.GetTile()), TileY(m_destTile)); |
143 assert(dx >= 0 && dy >= 0); |
143 assert(dx >= 0 && dy >= 0); |
144 int dd = min(dx, dy); |
144 int dd = min(dx, dy); |
145 int dxy = abs(dx - dy); |
145 int dxy = abs(dx - dy); |
146 int d = 14 * dd + 10 * dxy; |
146 int d = 14 * dd + 10 * dxy; |
147 n.m_estimate = n.m_cost + d /*+ d / 8*/; |
147 n.m_estimate = n.m_cost + d /*+ d / 8*/; |