How to randomly choose between 2 possible paths with AStar API?

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

For my npc movement AI I’m using godot’s built in AStar class, it works pretty well except that when there are 2 possible paths (for example, go up then right or go right then up) it always picks the same one (right first then up), it’s never random.
How could I include randomness to the paths?

:bust_in_silhouette: Reply From: glenneric1

You could either temporarily or periodically adjust the weights of the path points in question, by a tiny amount (say 1.0 to 1.01). Or you could temporarily or periodically disable and reenable said points. If you didn’t want to keep track of those points on a per path basis you might just periodically sweep the grid, toggling weights from 1.0 to 1.01. Just my two cents since I haven’t actually begun programming yet :stuck_out_tongue: