@Override
	public void process(SimEvent event) {
		NodeReachedEvent _event = (NodeReachedEvent) event;
		this.setPosition(_event.getPosition()); //Sets the actual position to the one provided by the event.
		System.out.println(getName() + "@" + getEngine().getCurrentTime() + ": reached node (" + getPosition().getX() + "," + getPosition().getY() + ")");
		getLog().addNode(getPosition(), getEngine().getCurrentTime()); // Save the reached Node to the log.
		
		if(getLabyrinth().isEndpoint(getPosition())){
			System.out.println(getName() + ": finished");
			getEngine().stop();
		}
		else{
		
			// The meta object for the actual position is fetched. If none exists a new one is created.
			ShannonMouseNodeMeta _nodeMeta = null;
			Object _nodeMetaObj = getLabyrinth().getNodeMeta(getPosition(), getName());
			if(_nodeMetaObj == null){
				_nodeMeta = new ShannonMouseNodeMeta();
			}
			else{
				_nodeMeta = (ShannonMouseNodeMeta) _nodeMetaObj;
			}
			
			setDirection(_nodeMeta.getDirection()); // Sets the agents direction to the marker's.
			
			//Starting from the marker's direction, the agent searches for a new path clockwise.
			setDirection(getDirection() + 90);
			while(getLabyrinth().isWallAhead(getPosition(), getDirection())){
				setDirection(getDirection() + 90);
			}
			
			_nodeMeta.setDirection(getDirection()); // Save the new marker.
			getLabyrinth().setNodeMeta(getPosition(), getName(), _nodeMeta);
			
			NodeReachedEvent _newEvent = new NodeReachedEvent(getLabyrinth().getNodeAhead(getPosition(), getDirection()), getEngine().getCurrentTime() + getTicksPerLength(), 1, this);
			getEngine().insertEvent(_newEvent);
		}
		
	}