class Agent {

	private int x = 50;
	private int y = 150;
	
	private Environment world = null;

	public Agent(Environment worldIn) {

		world = worldIn;

	}
	
	
	public void run () {
	
		int x = 0;
		
		do {
			x = this.x;
			double randomNumber = Math.random();
			if (randomNumber < 0.33) x--;
			if (randomNumber > 0.66) x++;
		} while ((x < 0) || (x > world.getWidth() - 1));
		this.x = x;
			
		int y = 0;
		do {
			y = this.y;
			double randomNumber = Math.random();
			if (randomNumber < 0.33) y--;
			if (randomNumber > 0.66) y++;
		} while ((y < 0) || (y > world.getHeight() - 1));
		this.y = y;
				
		if (world.getDataValue(x, y) > 10) {
			world.setDataValue(x, y, world.getDataValue(x, y) - 10);
		} else {
			world.setDataValue(x, y, 0);
		} 
	
	}
	
	
	
	public int getX() {
		return x;
	}
	
	public void setX(int xIn) {
		x = xIn;
	}
	
	public int getY() {
		return y;
	}
	
	public void setY(int yIn) {
		y = yIn;
	}
	
	
}