yellowstonegames / SquidLib

Useful tools for roguelike, role-playing, strategy, and other grid-based games in Java. Feedback is welcome!
Other
454 stars 46 forks source link

using DijkstraMap with FOV is awkward #158

Closed SquidPony closed 7 years ago

SquidPony commented 7 years ago

I'd like to be able to pass my FOV result directly into DijkstraMap to limit it's search to only FOV areas with visibility above some arbitrary value (although above 0 is probably fine as well)

As it stands, I think I have to calculate all locations on the map that are not seen by the FOV and pass those as impassible to DijkstraMap

Bonus extra cool if the DijkstraMap directly talks to the FOV last calculated result and I don't have to manually pass anything at run time after I've initialized the DijkstraMap to talk to the FOV

tommyettinger commented 7 years ago

There are some issues with doing this for AI pathfinding (it enables pillar dancing and makes an AI unable to find you as soon as you walk behind an obstacle). It should be fine for player path determination. Somewhat surprisingly, GreasedRegion makes this task fairly easy, since it can be calculated from an FOV double[][] with any minimum and it counts as a Collection<Coord>. I just committed an example of this in BasicDemo2 (in the display module's tests directory, not in examples like before). Check for the field blockage, and also maybe seen. FOV there is calculated with static methods to avoid allocating double[][]s all over the place.