Hey guys,
I have some homework which requires me to do a star search on a series of job courier deliveries.
This is the spec: http://pastebin.com/mWA4BrkB
We've been told there is no set grid and for the state space it is all the set of solutions possible.
This is what I have so far:
Node -
Code:
 
/* Class which describes a single node with an x and y coordinate */
public class Node {

	/* Constants defined here for clarity. */
	private int xCoord;
	private int yCoord;
	
	/* Node Constructor */
	public Node (int aXCoord, int aYCoord) { 
		
		xCoord = aXCoord;
		yCoord = aYCoord;
	}
	
	/* Methods */
	/**
	 * Gets the x coordinate of the node.
	 * @return x coordinate
	 */
	public int getXCoord () { 
		
		return this.xCoord;
	}
	
	/**
	 * Gets the y coordinate of the node
	 * @return y coordinate
	 */
	public int getYCoord () { 
		
		return this.yCoord;
	}
}
which is just an x and y coordinate
Edge -
Code:
 import java.lang.Math;

/* Class that defines an Edge between two nodes */
public class Edge {

	/* Constants defined here for clarity */
	private Node lastJobNode;
	private Node newJobNode;
	private double betweenJobDist;
	
	/* Constructor */
	public Edge (Node jobFinish, Node jobStart) { 
		
		lastJobNode = jobFinish;
		newJobNode = jobStart;
	}
	
	/* Methods */
	
	/**
	 * Gets the travel distance between two jobs defined in the edge
	 * @return betweenJobDist
	 */
	public double getTravDistBetweenJobs () { 
		
		// for simplicity we calculate everything to square root first  
		double toAbs = Math.sqrt(newJobNode.getXCoord() - lastJobNode.getXCoord()) + (newJobNode.getYCoord() - lastJobNode.getXCoord());
		
		// then return the absolute value of the previous result
		return betweenJobDist = Math.abs(toAbs);
  	}
	
	public Node getConnectedEdge () { 
		
		return this.newJobNode;
	}
}
which is a connector from the end of a job to the beginning of a new job
Job -
Code:
 import java.lang.Math;

/* Class that defines the job between the start and end of a job */
public class Job {

	/* Constants declared here for clarity */
	private static double jobTravelDist;
	private static Node start;
	private static Node end;
	
	/* Constructor */ 
	public Job (Node jStart, Node jEnd) { 
		
		start = jStart;
		end = jEnd;
	}
	
	/* Methods */
	/**
	 * Gets the travel distance between the start and end of a job
	 * @return travelDistance
	 */
	public double getJobTravDist () { 
		
		// for simplicity we calculate everything to square root first  
		double toAbs = Math.sqrt(end.getXCoord() - start.getXCoord()) + (end.getYCoord() - start.getXCoord());
		
		// then return the absolute value of the previous result
		return jobTravelDist = Math.abs(toAbs);
  	}
	
	public Node getJobEnd() { 
		
		return this.end;
	}
	
}
which is a job which has a start and an end node
CourierDelivery -
Code:
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;


/* Main file which reads in input. */
public class CourierDelivery {

	/* Constants defined here for clarity. */
	private static HashMap<Node, Node> nodeList;
	private LinkedList<Node> emptyList;
	
	/* Main */
	public static void main (String[] args) { 
	
		try {
			// scans in input file
			Scanner sc = new Scanner(new FileReader("resources/input1"));
			CourierDelivery cDSystem = new CourierDelivery();
			// while the input file has another token
			while (sc.hasNext()) { 
				// string used for comparison
				String nxt = sc.next();
				
				// if it equals to Job
				if ("Job".equals(nxt)) {
					
					// gets the next int to accept and create start coordinates
					int xStart = sc.nextInt();
					int yStart = sc.nextInt();
					Node startNode = new Node(xStart, yStart);	
					
					// progresses it forward one string to accept and create destination coordinates
					sc.next();
					int xDest = sc.nextInt();
					int yDest = sc.nextInt();
					Node endNode = new Node (xDest, yDest);
					
					// inserts the above two nodes to the map 
					cDSystem.createMapXY (startNode, endNode);
					
					// creates a job for the start and end nodes
					Job newJob = new Job (startNode, endNode);
				} else { 
					System.out.println("no");
				}
				//cDSystem.printMap();
			}
		}
		catch (FileNotFoundException e) {}
	}
	
	/* Constructor */
	public CourierDelivery () { 
		
		nodeList = new HashMap<Node, Node>();
	}
	
	/* Methods */
	/**
	 * Creates a mapping for a job from the start to end node
	 * @param startNode	where the job starts
	 * @param endNode	where the job ends 
	 */
	public void createMapXY (Node startNode, Node endNode) { 
		
		nodeList.put(startNode, endNode);
	}
	
	public void printMap () { 
		
		for (Node startNode : nodeList.keySet()) {
			System.out.print(startNode.getXCoord() + ", " + startNode.getYCoord());
			System.out.print(" -> ");
			for (Node endNode : nodeList.values()) {
				System.out.println(endNode.getXCoord() + ", " + endNode.getYCoord());
			}
		}
	}
        public void AStarSearch (Node start, Set emptySet) {
	
		LinkedList<Node> closedList = new LinkedList<Node>();
		PriorityQueue<Node> openList = new PriorityQueue<Node>();
		
		openList.add(start);
		
		while (!openList.isEmpty()) {
			Node current = openList.poll();
                        closedList.add(current);
               }
I don't really understand how to write the a star search function. I've tried looking at the psuedo code on wiki but it just confuses me. I've started it but I'm not entirely sure what to write for the comparison to check whether I've achieved the goal.
Any help provided would be greatly appreciated.