@Override
	public final Action choose(Robots.BLU actor, Set<Action> options) {
		// Here we assume that we will always see the same
		// actor. This will be true of many models, including
		// this one, but not always.

		// On the first call, our state will not be initialized
		// so we initialize it here once and use it on subsequent
		// calls.
		if(pathing == null) {
			// This agent is responsible for pathing our BLU actor from
			// its initial location to a goal state. We grab these locations
			// and create a Domain, which your pathing code will use to
			// perform the search.
			Location initial = actor.location();
			Location goal    = Groups.any(actor.targets());
			
			if(goal == null) { throw new Error("No goal state obtained!"); }
			
			Domain<Location> domain = new DomainBLU(actor, initial, goal);
			domain = new DomainTracker<Location>(domain);
			
			// Select a search method for use based on information
			// specified through the command line.
			Search<Location> method = null;
			switch(type) {
				case BREADTH         : method = new BreadthFirstSearch<Location>();
				                       break;
				case DEPTH           : method = new DepthFirstSearch<Location>();
				                       break;
				case ASTAR_EUCLIDIAN : method = new AStarSearch<Location>(
				                           new ConstantCostFunction<Location>(),
				                           new EuclidianHeuristic(goal)
				                       );
				                       break;
				case ASTAR_MANHATTAN : method = new AStarSearch<Location>(
				                           new ConstantCostFunction<Location>(),
				                           new ManhattanHeuristic(goal)
				                       );
				                       break;
				default: throw new Error("Unrecognized search type!");
			}
			
			// Here we verify we recieved a path. This agent
			// is guaranteed to be in a configuration in which
			// a path is possible.
			pathing = method.search(domain);
			
			if(pathing == null) { 
				throw new Error("No path recieved!");
			}
			
			// For the sake of testing and instrumentation, we
			// use the DomainTracker class to track the number
			// of expansions used by the search method.
			expansions = ((DomainTracker<Location>)domain).expandOrder();
		}

		// If we have reached the end of our path then there
		// is nothing we can do and so we just wait.
		if(pathing.isEmpty()) {
			return null;
		}
		
		// Finally we have verified post-conditions and can
		// make our move. We obtain the next location in the
		// path and we obtain the action available which will
		// move us there;
		Location next = pathing.remove(0);
		return actor.move(next, options);
	}