public Map generateMap(int timeToWait) {
		MapManager mapManager = new MapManager(width, height);
		ArrayList<AgentParams> spawnEvents = (ArrayList<AgentParams>) agentComposition
				.clone();
		ArrayList<AgentParams> removeList = new ArrayList<AgentParams>();
		int steps = 0;
		while (mapManager.agentsLeft() || spawnEvents.size() > 0) {
			// spawn the agents according to their spawn time
			for (AgentParams agentPar : spawnEvents) {
				if (agentPar.spawnTime == steps) {
					// pick a position inside the spawn circle
					double direction = Math.random() * 2.0 * Math.PI;
					double xDistance = Math.random() * agentPar.spawnRadius;
					double yDistance = Math.random() * agentPar.spawnRadius
							/ (width / height);
					int xPos = Math.max(
							Math.min(
									(int) (agentPar.pos.x + xDistance
											* Math.cos(direction)), width - 1),
							0);
					int yPos = Math
							.max(Math.min((int) (agentPar.pos.y + yDistance
									* Math.sin(direction)), height - 1), 0);
					Position spawnPos = new Position(xPos, yPos);

					// intialize the agent
					agentPar.agentType.clone().initialize(mapManager,
							agentPar.tokens, spawnPos, agentPar.waitingPeriod);
					removeList.add(agentPar);
				}
			}
			for (AgentParams toRemove : removeList) {
				spawnEvents.remove(toRemove);
			}
			removeList.clear();
			mapManager.performStep();

			if (timeToWait > 0) {
				System.out.println(mapManager.showMap());
				try {
					Thread.sleep(timeToWait);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}

			steps++;
			if (steps > maxGenerationSteps)
				break;
		}
		return mapManager.extractMap();
	}