Skip to content

strange paths, operator() called with UINT_MAX #6

@PcChip

Description

@PcChip

Hi,

I'm sure I'm doing something wrong here, but I'm stumped as to what

In my game, I replaced the normal A* pathfinder with your JPS version, and half the time the paths generated are perfect, but the other half of the time they're crazy. I started adding debugging and checks everywhere I could think of, and I noticed that operator() gets called with x and y being UINT_MAX (or -1 as a signed integer)

Is this expected behavior?

(Note the "< 9" part is because this was originally used in a variable cost pathfinding solution, but I just put in "< 9" for use with yours)

`inline bool teMapModule::operator()(unsigned int x, unsigned int y) const
{
bool canwalk = ((x < 512) && (y < 512) && (x >= 0) && (y >= 0));

if (canwalk)
{
	canwalk = pathingMap[y*512 + x] < 9;
}
return canwalk;

}

bool teMapModule::findJPSPath(int startingX, int startingY, int goalX, int goalY, std::vector<xzCoordsStruct>& resultingPath)
{

JPS_Path_Results.clear();
JPS::Position start{startingX,startingY};
JPS::Position goal{goalX,goalY};  
bool pathFound = JPS_Searcher->findPath(JPS_Path_Results, start,goal, 1); 

if(pathFound)
{
	for (JPS::PathVector::iterator it = JPS_Path_Results.begin(); it != JPS_Path_Results.end(); ++it)
	{
		resultingPath.push_back({ it->x ,it->y });
	}
}
return pathFound;

}`

Can you see any obvious errors or have any idea why I'm getting crazy paths half the time?

Thanks for any suggestions you might have!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions