JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
760 stars 126 forks source link

Code duplicacy in pathfinding and continuous space #563

Open AayushSabharwal opened 3 years ago

AayushSabharwal commented 3 years ago

Currently we have a bit of code duplicacy in submodules/pathfinding/astar_continuous.jl and spaces/utilities.jl/spaces/continuous.jl

This should be solvable without breaking changes. Is there a necessity for get_spatial_index to return a CartesianIndex? It should be able to be combined with to_discrete_position, and maybe some appropriately named function for the reverse conversion (currently handled by to_continuous_position).

Similarly, edistance could just return the sqrt of sqr_distance. Perhaps sqr_distance can have the signature sqr_distance{P}(a, b), so it dispatches on periodicity. This is required since sqr_distance currently dispatches on the periodicity of AStar whereas edistance does on that of the space.

I'll try and think of something for the third point, there's probably a nifty little trick with sign that would make it work

Datseris commented 2 years ago

@AayushSabharwal was this resolved in 5.0?

AayushSabharwal commented 2 years ago

It hasn't been resolved yet. It isn't a breaking change, so it can be released in a future patch version