Whoo! Working on a prototype again after more than a year! So I need some help with the logic here, maybe its just late, but i cant figure out why this isnt working:
neighbours is a map that stores nearby nodes where the key = distance, value = node_id
connections is a list of nodes that this node is connected to
Code:
ind = ds_map_find_first(neighbours); // Get the nearest neighbour
val = ds_map_find_value(neighbours, ind); // Get its ID
ds_map_delete(neighbours, ind); // Its been processed, so it is no longer a neighbour
if (((val.owner == 0) or (val.owner == 1)) and //if there is no owner or it is owned by the player
(ds_list_find_index(connections, val) < 0) { // if we're not already connected, /**** this line doesnt seem to work correctly ****/
ds_list_add(connections, val) // connect to it
numConnections += 1
ds_list_add(val.connections, self) // add this node to the new node
val.numConnections += 1
val.owner = 1 // affirm that we now own it
}
So if I have two nodes: Bob and Andy.
Bob connects to Andy fine
Andy then connects to Bob, even though they're already connected