diff options
author | tom <tom@ground-control> | 2015-11-25 15:36:50 -0600 |
---|---|---|
committer | tom <tom@ground-control> | 2015-11-25 15:36:50 -0600 |
commit | 0fb714b1a642361eebadf7d74333c20f861354d2 (patch) | |
tree | b1d43d8744b8637c83d1b0c5e9053a3c38fba437 /src | |
parent | e63a678a8fdde888620b6d5a5059bd0f37141592 (diff) |
fixed heuristic movement
Diffstat (limited to 'src')
-rw-r--r-- | src/Character.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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 <Character> men, vector <Location> 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<v) { L = open[i]; @@ -69,6 +69,8 @@ void Character::heuristic(vector <Character> men, vector <Location> impassable) } } move(L); + if(l.x==d.x && l.y==d.y) + order="wait"; } vector <Location> Character::getLocal(Location L, vector <Character> men, vector <Location> impassable) |