#Pathfinding Help

1 messages · Page 1 of 1 (latest)

vivid sapphire
#

So the gist of my algorithm is, set all costs to infinity, set the goal node's cost to 0 at the start, add the goal node index to the open list. loop through the open list > set current node. loop through all neighbors of current node and do cost calculations on them > grab neighbor with the lowest cost > add it to the open list > repeat until entire graph is visited. but the problem is after i add the goal node's neighbor with the lowest cost to the open list and then attempt to do the same on that node, that node's best cost neighbor is the goal node. so it keeps going back and forth adding the goal node and that neighbor node to the open list over and over. never getting to explore the rest of the graph. how would i go about finding the UNVISITED neighbor with the lowest cost?

sand quail
#

I've tested it, once a node is visited, it cannot get a lower pathlength

#

So instead of keeping track of ALL costs, just keep track of unvisted costs, setting the costs of visited nodes to infinity

fossil knoll
#

I wish I knew what this meant I'm still trying to learn🙏

vivid sapphire
vivid sapphire
# sand quail After

finally got it working with pathlength instead of the crappy BFS method tysm 🙂

#

now comes optimization hell 😦

vivid sapphire
fossil knoll
fallen minnow
scenic quartz
scenic quartz
# sand quail yes

but what i did was when calculating the path to the goal i made it so every node had only 1 neighbor saved up wich was the lowest

scenic quartz
sand quail
#

yes

sand quail
#

thats called a line

scenic quartz
scenic quartz
#

wont it go in a loop?

sand quail
scenic quartz
sand quail
#

Your pathfinding algorithm keeps track of visited nodes via a List<Int> or List<Rec Room Object>, i prefer a List<Int>

When a node is visited, you add it (or its index) into the list

sand quail
#

spoiler

scenic quartz
#

and it chose the lowest one

sand quail
#

look i've explained pathfinding enough times just go find one of them

scenic quartz
#

like the nearest from the current node

sand quail
#

im trying to do stuff rn

vivid sapphire
sand quail
#

but you dont have any speed statistics

#

my algorithm takes 0.0037s per node to run at 30% CPU (~2 seconds for 540 nodes)

#

Divide the time it takes to calculate the algorithm by the number of nodes you have

The timer should start once you start calculating the algorithm (not before its initialized, eg. not before it hasnt been reset for a new path) and stop once you have visited all (possible) nodes, eg. when it finishes

scenic quartz
sand quail
scenic quartz
sand quail
#

oh, a node baker? that can take a LONG time

#

for my 540 nodes, my fastest time is like 3 minutes

#

but thats because you should only have to do it once, then it should be baked