pybrood
pybrood copied to clipboard
Why isn't Position/TilePosition/WalkPosition wrapped?
I'm trying to understand the decision to convert all Positions into integer arrays. You lose type safety and methods like getDistance().
It was intended for wrapping on python side to avoid round-tripping C++ bridge for small scalar types. Isn't getDistance just euclidean metric? Some experiments needed to figure out what will be more efficient.
I agree that it needs measurement, just be aware that getApproxDistance uses an optimized algorithm that matches the one used in-game:
int getApproxDistance(const Point<T,Scale> &position) const
{
unsigned int min = abs((int)(this->x - position.x));
unsigned int max = abs((int)(this->y - position.y));
if ( max < min )
std::swap(min, max);
if ( min < (max >> 2) )
return max;
unsigned int minCalc = (3*min) >> 3;
return (minCalc >> 5) + minCalc + max - (max >> 4) - (max >> 6);
};