Tutorial or example on a* pathfinding without Slick

Hey guys i was wondering if anyone knows of any references to any tutorials or example code that can do A* pathfinding? looked around but cant find any that is not tied into Slick

Has interactive examples.

From google of “a star pathfinding”

Here is the pathfinding code I made up a little while ago.


implement the [icode]TileMap[/icode] interface to access tiles, and implement the [icode]ITile[/icode] interface with each tile object. The [icode]Pathfinder[/icode] class does the actual pathfinding. If I remember correctly this is the pathfinding code I fixed up.

I have seen this, i just needed to see a good implementation of it

Ill check it out now, thanks

I forgot my [icode]Path[/icode] class.

package game.util;

import java.util.ArrayList;
import java.util.LinkedList;

public class Path {
	private LinkedList<ITile> ordered = new LinkedList<ITile>();
	public ArrayList<ITile> searched = new ArrayList<ITile>();
	private long millis;
	private int index = 0;
	private ITile start, end;
	private ITile lastuploaded;
	public int length() {
		return ordered.size();
	public void removeLast(){
	public void setOverall(ITile start, ITile end){
		this.start = start;
		this.end = end;
	public Path transform(int dx, int dy) {
		Path path = new Path();
		path.start = new ITile(start.tx + dx, start.ty + dy);
		path.end = new ITile(end.tx + dx, end.ty + dy);
		for (ITile tile : ordered) {
			path.ordered.add(new ITile(tile.tx + dx, tile.ty + dy));
		return path;
	public boolean next(){
		return index++ < ordered.size();
	public ITile last(){
		return ordered.getLast();
	public void setMillis(long millis){
		this.millis = millis;
	public long getMillis(){
		return millis;
	public ITile getTile(int index){
		return ordered.get(index);
	public ITile getNextTile(){
		return ordered.get(index);
	public void addTile(ITile tile){
		lastuploaded = tile;
	public void appendPath(Path path){
	public void wipe(){
		index = 0;


i seen thanks :slight_smile:

I found this: http://pastebin.java-gaming.org/30d824f780e1f
Note: might be subtly broken, or at least not algorithmically perfect.

How do you initialize TileMap?

TileMap tileMap = new TileMap(); //throws a error

It’s also not a library, merely a translation of the redblobgames tutorial wrapped in a demo.

[icode]TileMap[/icode] is abstract, a ‘template’ of a TileMap; you have to subclass it:

[icode]Line 27…58[/icode]

TileMap map = new TileMap() {

If you want a drop in solution, then this isn’t it. But you did ask for an example.

If you are referring to my code snippet, then:

TileMap is an interface that you must implement with another object that stores the tile objects (which must store objects extending the ITile class) .

Yeah im struggling to understand that (never used interfaces) could i see a example where you have used it for reference?

Because i kinda get it but im not all the way there

public interface Loadable {

	public void load();


public class Resource implements Loadable {

	public void load() {


public class Text implements Loadable {

	public void load() {


public void loadAll(ArrayList<Loadable> objects) {
	for (Loadable loadable : objects)

How have you managed to code Horizon (or whatever its called) without knowing about interfaces? Do you use the abstract modifier for your methods a lot and then extend that base class?

This is (IMO) still the best way to learn the basics of A*:

Idk i just have xD i don’t really find them useful for what im doing, but i see there uses in some cases


I have published some code to have a smoother a* if you need it: