Use Astar2D to get points under cost

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By astrale-sharp

Hello,

Im working on a tactical rpg

for moving on the board, entity have a number of point which is the max cost they’re allowed in an astar._compute_cost ( the_place_they_are_id,the_place_they_wanna_be_id)

for instance, if the cost for moving from id 0 to id 5 is 10
if movepoint > 10: the entity can move there
otherwise: it cannot

Right Now I implement my own Astar to be able to get all id’s under the cost: move point
As far as I’m aware this is not possible using Astar (a workaround would be testing all id’s but the performance would be terrible …)
So i wanted to know, is there a way I dont know of or should I make a feature proposal?

Thanks!

:bust_in_silhouette: Reply From: KohuGaly

Unfortunately, A* algorithm ( including Godot’s Astar) is not build for such thing. It is specifically for finding shortest path between two known points. What you need is something like a Dijkstra map. As luck would have it, I’ve implemented one just yesterday as a GDNative plugin. I posted about on reddit yesterday: link is here
I haven’t released it yet, because there’s still some work to do to put it into a presentable state (for example, documentation needs to be written). If you contact me, I may send you what I currently have.

Wow, what a luck :wink:

In fact I build one in gdscript but as you expect, performance is kind of … lets say very bad at least :wink:

In Rust?! <3 <3
“because C and C++ give me PTSD” so so fair !

Well i would be more than happy if you shared your code with me, one step further I would be happy to contribute to it if it makes its way to github or an alternatives :wink:
(Now is strangely not when I have the most time since I have a very hard competitive exam for when the confinement is over u u but apart from that … :slight_smile: )

astrale-sharp | 2020-04-20 15:18

Hello, I’m back. I’ve created a github for the dijkstra map project. Details are in this reddit comment.

KohuGaly | 2020-04-22 19:19