PathFinding.js icon indicating copy to clipboard operation
PathFinding.js copied to clipboard

Copying Grid

Open CDCollier opened this issue 5 years ago • 2 comments

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:

  1. Create default grid.
  2. Clone default grid to objects.
  3. Decision logic to determine destination.
  4. findPath()
  5. Update default grid.
  6. Repeat 2-5.

Am I on the right track?

Chrys

CDCollier avatar Dec 06 '19 05:12 CDCollier

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).

brean avatar Dec 07 '19 16:12 brean

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.

CDCollier avatar Dec 09 '19 05:12 CDCollier