summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2017-05-16 14:46:13 +0300
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2017-05-22 15:55:49 +0300
commitbd91730347b33fd88d3944dc63fed06655f0b736 (patch)
treec69733884e825d2a58744251e34115cf47b2257d /core/math
parentce2077262a967cd9020d54059a03a11f33d15c01 (diff)
Fix weigth scale of A* being applied to the whole path and estimation
Attempt to fix #8584
Diffstat (limited to 'core/math')
-rw-r--r--core/math/a_star.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index c327f7ca44..2a3fd79cad 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -190,8 +190,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
Point *n = begin_point->neighbours[i];
n->prev_point = begin_point;
- n->distance = _compute_cost(n->id, begin_point->id);
- n->distance *= n->weight_scale;
+ n->distance = _compute_cost(begin_point->id, n->id) * n->weight_scale;
n->last_pass = pass;
open_list.add(&n->list);
@@ -219,7 +218,6 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
real_t cost = p->distance;
cost += _estimate_cost(p->id, end_point->id);
- cost *= p->weight_scale;
if (cost < least_cost) {
@@ -236,8 +234,7 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
Point *e = p->neighbours[i];
- real_t distance = _compute_cost(p->id, e->id) + p->distance;
- distance *= e->weight_scale;
+ real_t distance = _compute_cost(p->id, e->id) * e->weight_scale + p->distance;
if (e->last_pass == pass) {
//oh this was visited already, can we win the cost?