Skip to content

Instantly share code, notes, and snippets.

@pxpc2
Created August 20, 2012 22:50
Show Gist options
  • Select an option

  • Save pxpc2/3408822 to your computer and use it in GitHub Desktop.

Select an option

Save pxpc2/3408822 to your computer and use it in GitHub Desktop.
public class Node {
public Node parent;
int x, y, flag;
int cost;
public Node(int x, int y, int flag) {
this.x = x;
this.y = y;
this.flag = flag;
}
public Node[] getNeighbours() {
return new Node[]{
nodes[x - 1][y],
nodes[x + 1][y],
nodes[x][y - 1],
nodes[x][y + 1]
};
}
@Override
public boolean equals(final Object o) {
if (o instanceof Node) {
final Node n = (Node) o;
return this.x == n.x && this.y == n.y
&& this.cost == n.cost;
}
return false;
}
public Tile toTile(int bX, int bY, int plane) {
return new Tile(x + bX, y + bY, plane);
}
@Override
public String toString() {
return ("(" + x + ", " + y + ")");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment