|
| 03 Jun 2012 02:30 PM |
So, I have one table that is full of all the nodes and every node has its information (position, neighbors, F, G, H, ect.) in it. I was thinking that my OpenNodes and ClosedNodes tables should only have the position value of the node and not replicated data but I'm not sure how I would be able to remove the node numbers from each of the tables without going though and looking for the position with the actual value. I'm thinking that the position will already be known because you have to find which node you are dealing with already but it would be another variable I would have to worry about handling. What do y'all think is the best way to do this?
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 03 Jun 2012 02:31 PM |
ROBLOX does it liek this:
local G = {} local F = {} local H = {}
And then reference it to a 'Node name'...
|
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 02:36 PM |
"ROBLOX does it liek this:"
Wut?
I do this:
function CreateNodes() _G.Nodes = {} Dots = game.Workspace.Nodes:GetChildren()
for i = 1, #Dots do --------------{ Position x , Position z , Node's Neighbors _G.Nodes[i] = { ["x"] = Dots[i].Position.x, ["z"] = Dots[i].Position.z , ["Neighbors"] = {} --, Parent Node , F Score , G Score , H Score } , ["Parent"] = nil, ["F_Score"] = nil, ["G_Score"] = nil, ["H_Score"] = nil,} end end
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 02:37 PM |
I'm tired of the forum eating the white-space... THEY REALLY NEED TO GIVE US A [code] tag or something....
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 03 Jun 2012 02:39 PM |
I think I would do it Quenty's way.
There have been a lot of pathfinding threads lately, maybe we should make one thread to discuss anything that has to do with pathfinding. Including ways to tweak it for different kinds of games. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 02:40 PM |
Why his way?
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 03 Jun 2012 02:43 PM |
| You can sort the table of f-scores easier which is useful for making it more efficient. That's just opinion though, there is probably a way to make yours efficient, too. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 02:45 PM |
"You can sort the table of f-scores easier "
Then how can you tell which f-score goes to each node?
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
Flurite
|
  |
| Joined: 03 Apr 2011 |
| Total Posts: 5386 |
|
|
| 03 Jun 2012 02:46 PM |
| I would store all the scores as as an Int/Number Value because that makes things simple, in my opinion. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 03 Jun 2012 02:46 PM |
That is ROBLOX's way.
My way is generally creating a table so I can do..
Node.F Node.H
ClosedSet[#ClosedSet+1] = Node OpenSet[NodeIndex] = nil
|
|
|
| Report Abuse |
|
|
lah30303
|
  |
| Joined: 15 Feb 2008 |
| Total Posts: 10027 |
|
|
| 03 Jun 2012 02:48 PM |
| You can keep a separate table for each of the nodes that tells which position in the F table that the node's F score is in. Then whenever it's position in the table changes you also change the value in the separate table. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 02:51 PM |
I'll just do it my way...
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 03 Jun 2012 02:56 PM |
| Try to use local variables, not stuff in the _G table for efficiency. |
|
|
| Report Abuse |
|
|
|
| 03 Jun 2012 03:01 PM |
The only times I use Global are when I am saving all the nodes into the _G.Nodes and when I am copying them all into a variable for use in the individual AI scripts.
~Read Between The Squiggles~ |
|
|
| Report Abuse |
|
|