#Bi-directional A*
1 messages · Page 1 of 1 (latest)
Grid script: https://paste.ofcode.org/WqqAzjm7qcpYEhZBjULEaU Node script: https://paste.ofcode.org/358rVjUzDAuunDdPrX2ytr5
Is that ok?
yes, the fcost in your node class is not being set
so do your algorithm run correctly after you set the fcost?
There’s no errors to be honest
But isn’t the fCost established in line 27 of the node script
Implementation of bi-directional is hard to find on YouTube
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)
Aight. Working on the draw line debug method
So what’s the best solution?
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
Alright
Thanks so far ma man🔥
The Player option in the Reverse Grid Script, should I place the target or seeker?
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
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
in your BiDirectionalPathfinding.cs you have already reference to target and seeker
i see your debug message, something go wrong when retrace path
i think your retrace path is wrong
give me some time
!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.
I obviously have to alter the grid scripts?
i think you dont need to
So in the Grid and Reverse Grid options, I should choose the Grid.cs?
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[,]
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.
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
The error’s telling me reversegrid is anot attached in awake class
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
On it 👌🏻
I’m getting outofmemory too often. Damn.
Removed reversegrid, and have a variable isForwardSearch = Tue, for forward search and false, for reverse
exception?