Added type alias for std::pair<uint8_t,uint8_t> for grid coordinates as sf::Vector2 cannot be used in std::map or std::set

This commit is contained in:
trotFunky 2019-06-08 16:11:29 +02:00
parent 430d2b0307
commit 633fda8336
5 changed files with 24 additions and 12 deletions

View file

@ -12,6 +12,8 @@
namespace pro_maat
{
// Used with positions on the map grid
using GridPos = std::pair<uint8_t,uint8_t>;
static constexpr uint8_t pixelsPerUnit = 50;
static constexpr char levelFolder[] = "resources/";
@ -20,6 +22,14 @@ 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;
}
}
#endif //PROJECT_MAAT_UTILS_H