All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lejos.robotics.pathfinding.GridNode Maven / Gradle / Ivy

Go to download

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);
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy