@Override
	public void process(SimEvent event) {
		NodeReachedEvent _event = (NodeReachedEvent) event;
		this.setPosition(_event.getNode()); // Sets the actual position to the reached node.
		System.out.println(getName() + "@" + getEngine().getCurrentTime() + ": reached node " + getPosition());
		getLog().addNode(getPosition(), getEngine().getCurrentTime()); // Save the reached Node to the log.
		
		if(getLabyrinth().isEndpoint(getPosition())){
			System.out.println(getName() + ": finished");
			getEngine().stop(); 
		} else{
			
			LinkedList<Integer> _edges = getLabyrinth().getEdges(getPosition()); // Fetches the edges of the current node.
			
			// Select the new edge.
			
			int _edgeListIndex = 0;
			for (int i = 0; i < _edges.size(); i++) {
				if (lastEdge == _edges.get(i)) {
					_edgeListIndex = i;
				}
			}
			
			if ((_edgeListIndex + 1) >= _edges.size()){
				_edgeListIndex = 0;
			}
			else{
				_edgeListIndex++;
			}
			
			int _newEdge = _edges.get(_edgeListIndex);
			lastEdge = _newEdge; // save Edge to use it in the next step
			
			// Fetch the node behind the new edge.
			int _newNode = getLabyrinth().getNodeBehind(getPosition(), _newEdge);
			
			NodeReachedEvent _newEvent = new NodeReachedEvent(_newNode, _event.getOccurringTime() + getTicksPerLength() * getLabyrinth().getEdgeLength(_newEdge), 1, this);
			getEngine().insertEvent(_newEvent);
		}
	}