Reputation: 33
I'm trying to make a map using "Graphnodes" and coordinates where it would form a grid. I'm doing this first filling every coordinate in with a graphnode, and then going back through and connecting them all up. When I'm going through it tells me that key {2,1} is not in the dictionary but when I check the dictionary, the key and graphnode ARE there.
For i = 1 To MapSize
For j = 1 To MapSize
If i = 1 And j = 1 Then
temp = {i, j}
nodes.Add(temp, rootNode)
Else
roomKeyVal += 1
temp = {i, j}
nodes.Add(temp, New graphNode With {.Key = roomKeyVal})
End If
Next
Next
For i = 1 To MapSize
For j = 1 To MapSize
If i = MapSize Then
If j <> MapSize Then
nodes({i, j}).South = nodes({i, j + 1})
nodes({i, j + 1}).North = nodes({i, j})
End If
Else
If j = MapSize Then
nodes({i, j}).East = nodes({i + 1, j})
nodes({i + 1, j}).West = nodes({i, j})
Else
nodes({i, j}).East = nodes({i + 1, j})
nodes({i + 1, j}).West = nodes({i, j})
nodes({i, j}).South = nodes({i, j + 1})
nodes({i, j + 1}).North = nodes({i, j})
End If
End If
Next
Next
I need to have an interconnected grid of graphnodes that I can "travel" through but it can't get past connecting the third graphnode.
P.S. if you need help understanding the code, let me know what.
Upvotes: 0
Views: 62
Reputation: 33
Answered in comments. I changed the key in the dictionary from an array to one string. :)
Upvotes: 0