@Override
	public MovementAction testAction(Creature c) {
		Direction action = this.checkForDirt(c);
		if (action != null){
			currentDirection = action;
			return Direction.convertDirToAct(action);
		}
		int value = -1;
		int dist = -1;
		Sensor s = c.getSensor();
		if (currentDirection != null){
			value = (int) s.getSense(currentDirection.name() + DirtBasedAgentSenseConfig.TYPE_SUFFIX).getValue();
			dist = (int) s.getSense(currentDirection.name() + DirtBasedAgentSenseConfig.DISTANCE_SUFFIX).getValue();
			
			if (value == Environment.WALL && dist == Environment.CLOSE){
				currentDirection = null;
			}
		}
		
		if (currentDirection != null){
			return Direction.convertDirToAct(currentDirection);
		}
		
		ArrayList<Direction> possibleDir = new ArrayList<Direction>();
		for (Direction d : Direction.values()){
			value = (int) s.getSense(d.name() + DirtBasedAgentSenseConfig.TYPE_SUFFIX).getValue();
			dist = (int) s.getSense(d.name() + DirtBasedAgentSenseConfig.DISTANCE_SUFFIX).getValue();
			
			if (value == Environment.WALL && dist == Environment.FAR){
				possibleDir.add(d);
			}
		}
		value = r.nextInt(possibleDir.size());
		currentDirection = possibleDir.get(value);
		return Direction.convertDirToAct(possibleDir.get(value));
		
	}