@Override
	public STATUS run(Context context)
	{	
		pcContext = (PacManContext)context;

		ArrayList<Integer> targets = new ArrayList<Integer>();
		
		boolean powerPillActive = false;
		
		int ghostCounter = 0, ghostSpawnTimeTotal = 0;
		int[] ghostPositions = new int[4];
		int[] activePowerPills = pcContext.activePowerPills;
		int[] activePills = pcContext.activePills;
		
		// Figure out if a power pill is active.
		for (GHOST ghost : GHOST.values())
		{
			ghostPositions[ghostCounter] = pcContext.game.getGhostCurrentNodeIndex(ghost);
			ghostCounter++;
			ghostSpawnTimeTotal += pcContext.game.getGhostLairTime(ghost);
			
			if(pcContext.game.getGhostEdibleTime(ghost) > 0 && pcContext.game.getGhostLairTime(ghost) == 0)
				powerPillActive = true;
		}
		
		// If a power pill is not active and all ghosts have
		// spawned, add PPs to the list of targets
		if (!powerPillActive && (ghostSpawnTimeTotal == 0))
		{
			for(int i = 0; i < activePowerPills.length; i++)
			{
				int[] pathToPP = pcContext.game.getShortestPath(pcContext.currentPacManIndex, activePowerPills[i]);
				
				if (!pathContainsGhost(ghostPositions, pathToPP))
					targets.add(activePowerPills[i]);
			}
		}
		
		// If the list of targets is empty, add normal pills to it.
		if (targets.size() == 0)
			for(int i = 0; i < activePills.length; i++)
				targets.add(activePills[i]);
		
		pcContext.targetList = targets;
		
		return STATUS.SUCCESS;
	}