algorithms/q_learning/src/tudelft/rl/Agent.java
package tudelft.rl;

public class Agent {
	public int x,y;
	private int startX, startY;
	public int nrOfActionsSinceReset=0;
	
	public Agent(int startX, int startY) {
		this.startX=startX;
		this.startY=startY;
		x=startX;
		y=startY;
	}
	public State getState(Maze m) {
		return m.getState(this.x, this.y);
	}
	
	public State doAction(Action a, Maze m) {
		//executes an action and returns the new State the agent is in according to the Maze
		nrOfActionsSinceReset++;
		if (a.id.equals("up"))
			y--;
		if (a.id.equals("down"))
			y++;
		if (a.id.equals("left"))
			x--;
		if (a.id.equals("right"))
			x++;
		return getState(m);
	}
	
	public void reset() {
		System.out.println(nrOfActionsSinceReset);
		x=startX;
		y=startY;
		nrOfActionsSinceReset=0;
	}

	public boolean checkForReset() {
//		if (x == 24 && y == 14) reset();
		if (x == 9 && y == 9) reset();
		else if (x == 9 && y == 0) reset();
		else return false;
		return true;
	}
}
