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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DefaultIndexedGraph.getConnections could be simplified

InfectedBytes opened this issue · comments

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.

PR welcome :)

Done! 😃

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