Fixed target initialization still using sf::Vector2i

Forgot to move manhattanDistance to .cpp
This commit is contained in:
Teo-CD 2019-06-08 17:08:15 +02:00
parent f7481f2bc9
commit 250a680cad
3 changed files with 9 additions and 7 deletions

View file

@ -21,7 +21,7 @@ Entity::Entity(int x, int y, EntityType type, sf::Texture* texture, int width, i
currentState = State::Idle;
nextState = State::Idle;
target = sf::Vector2i(shape.getPosition());
target = pro_maat::GridPos(x,y);
nextTarget = target;
}

View file

@ -36,4 +36,11 @@ namespace pro_maat
window.display();
}
}
float manhattanDistance(pro_maat::GridPos leftHandSide, pro_maat::GridPos rightHandSide)
{
// The *0.01 helps with breaking ties and minimizing exploration
// As per http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html#breaking-ties
return (std::abs(rightHandSide.first-leftHandSide.first)+std::abs(rightHandSide.second-leftHandSide.second))*1.01;
}
}

View file

@ -23,12 +23,7 @@ static constexpr char fontFolder[] = "resources/";
void errorWindow(const std::string& error);
// Good heuristic on 4-way grids
double manhattanDistance(pro_maat::GridPos leftHandSide, pro_maat::GridPos rightHandSide)
{
// The *0.01 helps with breaking ties and minimizing exploration
// As per http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html#breaking-ties
return (std::abs(rightHandSide.first-leftHandSide.first)+std::abs(rightHandSide.second-leftHandSide.second))*1.01;
}
float manhattanDistance(pro_maat::GridPos leftHandSide, pro_maat::GridPos rightHandSide);
}