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?
#Pathfinding Help
1 messages · Page 1 of 1 (latest)
you stop keeping track of the lowest cost for visited nodes
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
I wish I knew what this meant I'm still trying to learn🙏
would you mark the current node as visited by setting it's cost to infinity before or after doing pathlength calculations on it's neighbors?
After
finally got it working with pathlength instead of the crappy BFS method tysm 🙂
now comes optimization hell 😦
You can take a look at it here https://rec.net/room/DijkstraFieldTestRRS2
I'll definitely check this out! you should also teach me😭🙏
Plants Vs Zombies football zombie
do you mean when u visit the node u make it inf?
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
and would i need an visited list
yes
if every node only has 1 neighbor, you dont need to pathfind
thats called a line
but lets say i have 100 ai and i want to make a heatmap how would i store visited node for each ai
you dont
so how does the ai know wich ones visited
wont it go in a loop?
Pathfinding is not related to AI
cuz u said the calculation i did is an line
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
yeah, because each node only had one neighbor, thats a line
spoiler
oh u got it wrong i think, i meant by that
Every node has like 4 neighbors
and it chose the lowest one
look i've explained pathfinding enough times just go find one of them
like the nearest from the current node
im trying to do stuff rn
sorry for the ping but do you think my vector field is good or na #circuits message
it works thats for sure
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
ay cryptic sorry for the ping too, is it normal that a node baker takes 48 seconds with only 58 nodes in a list
depends on how you did your circuits
Yeah but lets say u made an node baker how long should i usally take