PathFinding.js
PathFinding.js copied to clipboard
Copying Grid
Thank you for this! I have learned a lot already about AI searching since finding this project.
I identified the solution (I think) to how this is applied:
- Create default grid.
- Clone default grid to objects.
- Decision logic to determine destination.
- findPath()
- Update default grid.
- Repeat 2-5.
Am I on the right track?
Chrys
Looks good but it depends on what you want to do. Maybe you don't need to copy the grid if you go a path only once or you want to save some paths without changing the map (so ignore step 5).
A cell becomes walkable while a walker occupies it, and then unwalkable again when no walkers are present. I figured I would need to update and clone the default grid whenever a walker occupies a destination, so other walkers pick a different (unwalkable) destination.