libgdx / gdx-ai

Artificial Intelligence framework for games based on libGDX or not. Features: Steering Behaviors, Formation Motion, Pathfinding, Behavior Trees and Finite State Machines
Apache License 2.0
1.2k stars 242 forks source link

DefaultIndexedGraph.getConnections could be simplified #57

Closed InfectedBytes closed 8 years ago

InfectedBytes commented 8 years ago

I was looking through the pathfinding code and found this:

public Array<Connection<N>> getConnections (N fromNode) {
  return nodes.get(fromNode.getIndex()).getConnections();
}

fromNode.getIndex returns the index into the nodes-array. So nodes.get(fromNode.getIndex()) will return the fromNode itself. Basically you could just do the following

public Array<Connection<N>> getConnections (N fromNode) {
  return fromNode.getConnections();
}

Perhaps I overlooked something, but as it seems, the whole nodes-Array of the DefaultIndexedGraph is not really used.

davebaol commented 8 years ago

PR welcome :)

davebaol commented 8 years ago

Done! :smiley:

@InfectedBytes As a side note, I've added your libgdx jam game to the gdx-ai useful links.