Pathfinding Nodes

I’m looking for a code to resolve this problem:
I have world like this with this link between tiles (all them have same lenght cause it is something like “portal”) example i wanna go from Tiles A to F usually the fast solution it is A > C > D/G > F, but i wanna also try to avoid use D cause it is “bad”/penality in my world move into D.

Thanks for help.

This is called graph traversal and you can find a ton of articles online. The nomenclature is that nodes are called vertex / vertices, connections are called edges and distance is the heuristic “weight” of each vertex – so once you’ve picked the proper algorithm, assign a higher distance value to node D.

1 Like