Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Walkable tile will break routing if not on startup grid but added later. #14

Open
PiNotEqual3 opened this issue Feb 1, 2014 · 3 comments

Comments

@PiNotEqual3
Copy link

If you setup a grid were all tiles are 1 like [1,1,1,1,....], set tiles [1,2] as walkable and change the map during the game by setting one tile to 2 it will break the path finding. At first it will try to move around but if you keep recalculating the path it can't decide on one path and get stucked.

I am using the Phaser Plugin, I added a fix there: appsbu-de/phaser_plugin_pathfinding#1

Maybe you like to add it to your setAcceptableTiles(), too.

@sbj42
Copy link
Contributor

sbj42 commented Mar 26, 2017

I don't see how this is a problem with easystar. The collision grid and the acceptable tiles are independent variables, and so it shouldn't matter in what order you change them. Perhaps this was a problem specifiy to phaser_plugin_pathfinding?

@prettymuchbryce
Copy link
Owner

prettymuchbryce commented Mar 31, 2017

This seems like an issue with the expectations around state. Maybe @PiNotEqual3 expects that easystar will track his changes to his collisionGrid without explicitly having to call setGrid every time he updates it. It's an accidental side effect that this actually does kind of work. The part that doesn't work is the costMap which doesn't get properly initialized if the grid is changed to include a new tile without calling setGrid.

Maybe it makes sense to deep copy the grid passed into setGrid. We would incur a performance cost, but it might save users from some nasty state issues like this one. I will have to think about this more.

@justusromijn
Copy link

justusromijn commented Oct 29, 2018

I would suggest keeping easystar out of any state stuff, and require to call setGrid if you want to load a new grid (like a new level). For dynamic changes (like doors, bridges, etc) the avoid/stopAvoiding mechanism should suffice. Maybe it would help if this is documented a bit more clearly, with a unlockable door example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants