#pathfinding help

1 messages · Page 1 of 1 (latest)

dense gust
#

I'm making A* star and I don't know how to calculate h costs and g costs
Should I be using distance chip or ?

junior peak
#

Pathlength is calculated as you go, by default, every node should be infinity, except for start which should be 0. Every time you visit a node, you set its pathlength to CurrentNodePathLength + DistanceBetweenNodeAndCurrentNode, but only if CurrentNodePathLength + DistanceBetweenNodeAndCurrentNode + CurrentNodeDistanceToEnd (aka the would-be F value of this node) is less than the nodes stored F value

F Value or "Pathlength + Distance To End" is quite literally the path length of that node (Should be a List<Float>) plus the distance between that node and the end node (using Add and Distance)

dense gust
junior peak
#

Remember that path length does not equal distance from start

dense gust
junior peak
#

Yes

dense gust
#

Thanks 👍

fresh shore
# junior peak Yes

Yo cryptic so is this similar to the Dijkstra Method?
If yes can't I just like do this

The monsters closest node from it's Node destination

#

I already created the lists for the nodes and the path they can go

junior peak
fresh shore
junior peak
fresh shore
junior peak
fresh shore
#

Calculate the pathlenght

junior peak
#

Yes

fresh shore
#

Because im using Dijkstra

junior peak
#

Dijkstra's entire algorithm is "the next node to calculate is the node with the lowest pathlength that hasnt been visited yet"

#

A* is "The next node to calculate is the node with the lowest pathlength + distance from target that hasnt been visited yet"

fresh shore
junior peak
#

I dont think you understand how pathfinding works

#

if you had a list of paths from any node to any node, you wouldnt need to path find

fresh shore
#

I kinda do I just have to re-watch the vid again because the last time I watched it was weeks ago

junior peak
# fresh shore I kinda do I just have to re-watch the vid again because the last time I watched...

This is the fourth in a series of computer science videos about the graph data structure. This is an explanation of Dijkstra’s algorithm for finding the shortest path between one vertex in a graph and another. Indeed, this explains how Dijkstra’s shortest path algorithm generates a set of information that includes the shortest paths from a sta...

▶ Play video
fresh shore
#

That's the one I watched

#

By what I understand from it
That I need to have to lists

Each node
And every path the node can go to

fresh shore
#

Yes

junior peak
fresh shore
junior peak
junior peak
#

I give up

#

Pathfinding is hard

#

You’ll learn it eventually if you keep trying

#

or you wont, you’ll give up, learn more circuits, remember, get inspired, and start learning again

fresh shore
fresh shore
azure gale
azure gale
#

I kind of forgot how to use cryptics Astar. I had it working like a month ago but then I forgot how to do node connections ☠️

floral yew
#

Do you use invisible collisions as Nodes in recroom?

#

Or trigger volumes?

fresh shore
fresh shore
junior peak
fresh shore
junior peak
#

well, it doesnt need to be, but its faster

fresh shore
#

OK thx

azure gale
#

Don’t they both take the shortest route?

junior peak
azure gale
#

And by how faster?

#

Like by how much faster is A* than Dijkstra?

junior peak
#

well, depends on the maze

#

There is little but noticable difference in closed paths (Like a hallway game, or a game that takes place in a building), but there is a MASSIVE difference when in open areas

https://www.youtube.com/watch?v=g024lzsknDo

The project contains the Java implementation of the A* and Dijkstra path search algorithms, which can be used alone in any application. A GUI demo is provided for the visualization that animates the search progress, also shows the cost of the path and the number of nodes visited during the search, so the difference between the two algorithm coul...

▶ Play video
#

Notice how the "Cost" of both paths are equal, but disjtra visits WAY more nodes

azure gale
#

Jesus Christ

fresh shore
#

@junior peak
So Im trying to figure out how I should convert all of my paths in to my nodes so I can calculate the F cost

But a List get element can only have 1 Index that's it

How can I get the nodes checked all at once?

junior peak
#

F Cost is calculated as the path is found

#

You dont pre-bake your paths

fresh shore
junior peak
supple salmon
#

Custom for loops

junior peak
fresh shore
#

Ight, one more thing.

So u said I should calculate the F cost as the path is found, how am I supposed to do that

supple salmon
#

Distance from the node to the endpoint

fresh shore
supple salmon
#

I’ve only used dijkstras, but I think he means its calculated as the agent meets a node

junior peak
fresh shore
azure gale
junior peak
# fresh shore Yeah but what did he mean by "as the path is found"

A* yes?

When the pathfinding starts, you set the pathlength of every node to Infinity, except for the starting node, which gets set to 0, and you set the F Value of every node to 0, except for the start node, which gets set to Distance(Start, End)

After, you pick the node with the lowest F Value that hasnt been visited yet
Because every other node will be at Infinity except for the start node, it picks the start node first

It should now look at each one of its neighbors
If Current Node Pathlength + Distance(Current, Neighor) is less than the Pathlength of the neighbor node, set the path length of the neighbor node to Current Node Pathlength + Distance(Current, Neighbor), set the F Value of the neighbor node to Current Node Pathlength + Distance(Current, Neighor) + Distance(Neighbor, End), set the From Node of the neighbor node to Current Node (This is for filtering the path later)

When finished, it marks the Current Node as visited, then picks the node with the lowest F value that hasn't been visited yet, and repeats the above steps until it runs out of nodes, or Visited Nodes contains the target node

Once Visited Nodes contains the target node, you need to filter the path

Set Filtered Path to a List Create only containing the end node
Find the node the first node in the Filtered Path list in from, insert it in the first index of the Filtered Path
Repeat until Filtered Path contains the start node

supple salmon
#

How many loops run when you get the path once? For a 15 node setup

junior peak
#

Lists required are:
Pathlength
F Value
Visited Nodes
Unvisted Nodes
From Nodes
Filtered Path

junior peak
supple salmon
#

So it runs each loop once per node?

#

Btw it’s 2 am I’m just asking without thinking much

fresh shore
#

You Fr a fuckin life saver

#

I was stuck for hours

azure gale
dense gust
# azure gale So would 1 billion nodes take longer than 14 nodes? Also how would 1 billion nod...

String split With a string of any character with the length of 512 so
If ur string is "A" have a string of 512 A's set the seperator to the chosen character so in my case "A" this will give u a list of 512 items for a string list to get a list int plug the string list to a list get all indices of
Set the string to " "

I have no idea about 1 billion pretty sure he's just giving an example, a * doesn't go through all nodes, it goes through open node which u find as u go so it depends, a farther path takes more time than a shorter path

stray elk
azure gale
#

I’m guessing it’s for node connections?

dense gust
stray elk
dense gust
stray elk
stray elk
#

Thanks

fresh shore
stray elk
fresh shore
supple salmon
#

@junior peak I have a question if you don't mind. If you intend to make a never ending ai with can pathfind the same nodes over and over until it finds players, do I still need to label which ones have been visited and which haven't?

junior peak
#

yes

fresh shore
fresh shore
junior peak
#

mate like anything is possible in Cv2

#

just fuck around and find out

fresh shore
stray elk
#

What if you just got the neighbors of each node and then just checked the neighbor closest too the end node and repeated until you reach the end node

#

Wouldn’t this technically create the shortest path?

junior peak
stray elk
# junior peak thats what BFS is, and, no

Oh ok. But back to the A* system, when you order the string list like 1, 2, 3 would the “1, 2, and 3” be the elements on the list of vector3s? So “1” on the string list would represent the first element on the vector3 list?

#

If that makes sense

#

Otherwise which of the nodes would 1 on the string list represent

fresh shore
dense gust
fresh shore
dense gust
fresh shore
dense gust
fresh shore
#

Why would I have to provide a index in a list

dense gust
#

Also

#

To store f and h costs

fresh shore
#

Insert in list

#

Or add

dense gust
#

List set element

fresh shore
#

In a list

dense gust
#

That's the part of pathfinding

fresh shore
#

With the int if the F cost changes every time the ai has a new target

fresh shore
dense gust
#

U reset when the start the path search

junior peak
stray elk
#

Im guessing get the closest node then figure out the index of that node and set that as the end node?

fresh shore
stray elk
fresh shore
fresh shore
junior peak
fresh shore
fresh shore
junior peak
#

I know that A* uses F value and Pathlength
Pathlength = path length from start
F Value = Pathlength + Distance from end

tf is h value

stray elk
#

H dosen’t exist

junior peak
stray elk
junior peak
# stray elk I thought H cost was distance from from end?

oh fuck that would make sense

if pathlength = length of path and H cost = distance from end, then no @fresh shore you wouldnt need to store H cost, since you can always find that using Distance

F Value should be stored in a list, else you're just making Dijsktra

fresh shore
junior peak
fresh shore
#

Because the first node has to be distance (start, end)