tinypile
tinypile copied to clipboard
limit steps in Jump?
thank you very much. This is the best implementation I have seen.
When the scene has few obstacles (and cannot be reached directly), the execution efficiency will become worse. I found that when I limit steps in Jump, performance will get better. Can this be done?
I found that when I limit steps in Jump, performance will get better.
Got some code to demonstrate? Because right now i don't quite understand what you did and some more detail would be helpful. Also, if you have map data to share that exhibit this problem, please do. Having a test suite to characterize performance for different use cases would be great.
`struct GRID
{
bool bCanWalk;
};
struct GRID_DATA
{
GRID_DATA(){
w = 320;
h = 320;
for(int i = 0; i< 320; i++){
for(int j = 0; j<320; j++){
_data[i][j].bCanWalk = true;
}
}
for(int i = 150; i< 200; i++){
for(int j = 150; j<200; j++){
_data[i][j].bCanWalk = false;
}
}
}
inline bool operator()(uint32_t x, uint32_t y) const
{
if(x<w && y<h){
return _data[x][y].bCanWalk;
}else{
return false;
}
}
GRID _data[320][320];
uint32_t w, h;
};
... BOOL findPath(PV& path, Position start, Position end, uint32_t step, uint32_t nJumpStep = 0) { m_nJumpStep = nJumpStep; ... } ... Position Searcher<GRID>::jumpD { ... while(true) { ... if(m_nJumpStep && steps > m_nJumpStep) break; } ... }
int begin = 100; int end = 250; GRID_DATA grid_data; JPS::PathVector path; JPS::Searcher<GRID_DATA> search(grid_data); search.findPath(path, JPS::Pos(begin, begin), JPS::Pos(end, end), 0, 8); //
this is my test code.`