#Bi-directional A*

1 messages · Page 1 of 1 (latest)

hoary smelt
hoary smelt
#

Is that ok?

scarlet mountain
#

yes, the fcost in your node class is not being set
so do your algorithm run correctly after you set the fcost?

hoary smelt
#

There’s no errors to be honest

#

But isn’t the fCost established in line 27 of the node script

scarlet mountain
#

oh i see

#

sorry for that

hoary smelt
#

As oppose to my normal A*, it went like this

#

Ok. Ignore the voice

hoary smelt
#

Implementation of bi-directional is hard to find on YouTube

scarlet mountain
#

since i cant find any potential bugs and my bidirection implementation is quite different from you
so i would like to provide a way that make you debug much easier and you can see what is going on and your algorithm is running

#

when running your algorithm, use debug.drawline to show a tree like this (basically iterate through all the node explored and draw line between them and their parent)

#

i think one possible result your bidir a* not work is you use two different grid

#

since node is reference and and the closed set of forward search is referencing to forward grid and the closed set of reverse search is reference to the reverse grid
but i am not sure you can test it by store a reference to a node in grid then check if it is contain node in other grid:
set.Add(Node[0,0] from grid)
Debug.Log(set.Contains(Node[0,0] from reverse grid)

hoary smelt
#

Aight. Working on the draw line debug method

scarlet mountain
#

just running on the same grid
i see your node class already has some properties declared for reverse search
but i am not sure if my assumption is true, you may test it

hoary smelt
#

Alright

#

Thanks so far ma man🔥

#

The Player option in the Reverse Grid Script, should I place the target or seeker?

scarlet mountain
#

you can just get rid of the reverse grid script and run your path find and perform all checking on the Node[,] in normal grid script

#

and i cant see any reference or access to the player property in ReverseGrid.cs in BiDirectionalPathfinding.cs

hoary smelt
#

I think i merged the reversegrid in this

#

Do I have to ref the player property in BiDirectionalPathfinding.cs?

#

Coz my previous A* pathfinding had no ref to that

#

The reason why i separated the Pathfinding.cs and ReverseGrid was cause gpt suggested it would be better, if i had memory problems.

#

Which was true. I had lesser errors regards to memory

scarlet mountain
#

in your BiDirectionalPathfinding.cs you have already reference to target and seeker

hoary smelt
#

Debug.DrawLine has that effect

#

I moved the target closer by the way.

scarlet mountain
#

i see your debug message, something go wrong when retrace path

#

i think your retrace path is wrong

#

give me some time

#

!code

inner heraldBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

scarlet mountain
#

have a look and understand it
my code may have bugssss

hoary smelt
#

I obviously have to alter the grid scripts?

scarlet mountain
#

i think you dont need to

hoary smelt
#

So in the Grid and Reverse Grid options, I should choose the Grid.cs?

scarlet mountain
#

you can choose either one since they are both contain Node[,] but if you choose grid you can type fewer chars

#

since your node have space for storing data of both reverse and forward search, you can get and store the data with just one Node[,]

hoary smelt
#

Ahhh. I see. Makes more sense now.

#

I made a gameobject and attached the Grid.cs. Then, I input in the Grid component of the Pathfinding gameobject.

scarlet mountain
#

do you accessing grid?
i see line 22 and 21 have to access grid and you havent set it if your code doesnt changed

#

I have to sleep now if you have problems you can find others

hoary smelt
#

Goodnight man.

#

Thank you soo much 🫡🔥

hoary smelt
#

The error’s telling me reversegrid is anot attached in awake class

scarlet mountain
#

you can remove all reverseGird in your code only one grid (Node[,]) remaining in you path finding and the seeker and target both on the same Node[,]
and when running path finding
for forward search, set the properties reversed for forward search
for reverse search, set the properties reversed for reverse search

#

but you still need two open sets and closed sets for storing the state of forward search and reverse search

hoary smelt
#

On it 👌🏻

hoary smelt
#

I’m getting outofmemory too often. Damn.

#

Removed reversegrid, and have a variable isForwardSearch = Tue, for forward search and false, for reverse

scarlet mountain
#

exception?

hoary smelt
#

My dudeedeee

#

I got it already.

#

A faint debug line. But it will work.