From 0fb714b1a642361eebadf7d74333c20f861354d2 Mon Sep 17 00:00:00 2001 From: tom Date: Wed, 25 Nov 2015 15:36:50 -0600 Subject: fixed heuristic movement --- src/Character.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Character.cpp b/src/Character.cpp index 012b1a2..29f9d5c 100644 --- a/src/Character.cpp +++ b/src/Character.cpp @@ -53,15 +53,15 @@ void Character::heuristic(vector men, vector impassable) float v,u; Location L; + if(open.size()) { - v = sqrt(((open[0].x - d.x)^2) + ((open[0].y - d.y)^2)); + v = sqrt(pow(open[0].x - d.x,2) + pow(open[0].y - d.y,2)); L = open[0]; } for(int i = 0; i < open.size(); i++) { - u = sqrt(((open[i].x - d.x)^2) + ((open[i].y - d.y)^2)); - cout << u << " "; + u = sqrt(pow(open[i].x - d.x,2) + pow(open[i].y - d.y,2)); if (u men, vector impassable) } } move(L); + if(l.x==d.x && l.y==d.y) + order="wait"; } vector Character::getLocal(Location L, vector men, vector impassable) -- cgit v1.2.3