lejos.robotics.pathfinding.GridNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lejos-ev3-api Show documentation
Show all versions of lejos-ev3-api Show documentation
leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.
The newest version!
package lejos.robotics.pathfinding;
// TODO: Make this an invisible inner class.
public class GridNode extends Node {
private static float grid_space = 0; // TODO: Ruins possibility of using multiple grid sizes, saves memory.
// TODO: Override with alternate int, int constructor? Might make slightly faster, might not be worth it.
// TODO: Technically grid_space only needs to be set once by FourWayGridMesh. Not each time in each constructor.
public GridNode(float x, float y, float grid_space) {
super(x, y);
GridNode.grid_space = grid_space;
}
protected float calculateG(Node neighbor) {
return grid_space;
}
protected float calculateH(Node neighbor) {
return Math.abs(this.x - neighbor.x) + Math.abs(this.y - neighbor.y);
}
}