Program: 79863
Project: 79863
Buggy source:
@Override public void area1to1Encounters(boolean useTimeOfDay,boolean catchEmAll,boolean typeThemed,boolean usePowerLevels,boolean noLegendaries){
  checkPokemonRestrictions();
  List<EncounterSet> currentEncounters=this.getEncounters(useTimeOfDay);
  List<Pokemon> banned=this.bannedForWildEncounters();
  List<EncounterSet> scrambledEncounters=new ArrayList<EncounterSet>(currentEncounters);
  Collections.shuffle(scrambledEncounters,this.random);
  if (catchEmAll) {
    List<Pokemon> allPokes=noLegendaries ? new ArrayList<Pokemon>(noLegendaryList) : new ArrayList<Pokemon>(mainPokemonList);
    allPokes.removeAll(banned);
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      List<Pokemon> pickablePokemon=allPokes;
      if (area.bannedPokemon.size() > 0) {
        pickablePokemon=new ArrayList<Pokemon>(allPokes);
        pickablePokemon.removeAll(area.bannedPokemon);
      }
      for (      Pokemon areaPk : inArea) {
        if (pickablePokemon.size() == 0) {
          List<Pokemon> tempPickable=noLegendaries ? new ArrayList<Pokemon>(noLegendaryList) : new ArrayList<Pokemon>(mainPokemonList);
          tempPickable.removeAll(banned);
          tempPickable.removeAll(area.bannedPokemon);
          if (tempPickable.size() == 0) {
            throw new RandomizationException("String_Node_Str");
          }
          int picked=this.random.nextInt(tempPickable.size());
          Pokemon pickedMN=tempPickable.get(picked);
          areaMap.put(areaPk,pickedMN);
        }
 else {
          int picked=this.random.nextInt(allPokes.size());
          Pokemon pickedMN=allPokes.get(picked);
          areaMap.put(areaPk,pickedMN);
          pickablePokemon.remove(picked);
          if (allPokes != pickablePokemon) {
            allPokes.remove(pickedMN);
          }
          if (allPokes.size() == 0) {
            allPokes.addAll(noLegendaries ? noLegendaryList : mainPokemonList);
            allPokes.removeAll(banned);
            if (pickablePokemon != allPokes) {
              pickablePokemon.addAll(allPokes);
              pickablePokemon.removeAll(area.bannedPokemon);
            }
          }
        }
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
 else   if (typeThemed) {
    Map<Type,List<Pokemon>> cachedPokeLists=new TreeMap<Type,List<Pokemon>>();
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      List<Pokemon> possiblePokemon=null;
      int iterLoops=0;
      while (possiblePokemon == null && iterLoops < 10000) {
        Type areaTheme=randomType();
        if (!cachedPokeLists.containsKey(areaTheme)) {
          List<Pokemon> pType=pokemonOfType(areaTheme,noLegendaries);
          pType.removeAll(banned);
          cachedPokeLists.put(areaTheme,pType);
        }
        possiblePokemon=new ArrayList<Pokemon>(cachedPokeLists.get(areaTheme));
        if (area.bannedPokemon.size() > 0) {
          possiblePokemon.removeAll(area.bannedPokemon);
        }
        if (possiblePokemon.size() < inArea.size()) {
          possiblePokemon=null;
        }
        iterLoops++;
      }
      if (possiblePokemon == null) {
        throw new RandomizationException("String_Node_Str");
      }
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      for (      Pokemon areaPk : inArea) {
        int picked=this.random.nextInt(possiblePokemon.size());
        Pokemon pickedMN=possiblePokemon.get(picked);
        areaMap.put(areaPk,pickedMN);
        possiblePokemon.remove(picked);
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
 else   if (usePowerLevels) {
    List<Pokemon> allowedPokes=noLegendaries ? new ArrayList<Pokemon>(noLegendaryList) : new ArrayList<Pokemon>(mainPokemonList);
    allowedPokes.removeAll(banned);
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      List<Pokemon> usedPks=new ArrayList<Pokemon>();
      List<Pokemon> localAllowed=allowedPokes;
      if (area.bannedPokemon.size() > 0) {
        localAllowed=new ArrayList<Pokemon>(allowedPokes);
        localAllowed.removeAll(area.bannedPokemon);
      }
      for (      Pokemon areaPk : inArea) {
        Pokemon picked=pickWildPowerLvlReplacement(localAllowed,areaPk,false,usedPks);
        areaMap.put(areaPk,picked);
        usedPks.add(picked);
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
 else {
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      for (      Pokemon areaPk : inArea) {
        Pokemon picked=noLegendaries ? randomNonLegendaryPokemon() : randomPokemon();
        while (areaMap.containsValue(picked) || banned.contains(picked) || area.bannedPokemon.contains(picked)) {
          picked=noLegendaries ? randomNonLegendaryPokemon() : randomPokemon();
        }
        areaMap.put(areaPk,picked);
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
  setEncounters(useTimeOfDay,currentEncounters);
}

Fixed version (ground truth):
@Override public void area1to1Encounters(boolean useTimeOfDay,boolean catchEmAll,boolean typeThemed,boolean usePowerLevels,boolean noLegendaries){
  checkPokemonRestrictions();
  List<EncounterSet> currentEncounters=this.getEncounters(useTimeOfDay);
  List<Pokemon> banned=this.bannedForWildEncounters();
  List<EncounterSet> scrambledEncounters=new ArrayList<EncounterSet>(currentEncounters);
  Collections.shuffle(scrambledEncounters,this.random);
  if (catchEmAll) {
    List<Pokemon> allPokes=noLegendaries ? new ArrayList<Pokemon>(noLegendaryList) : new ArrayList<Pokemon>(mainPokemonList);
    allPokes.removeAll(banned);
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      List<Pokemon> pickablePokemon=allPokes;
      if (area.bannedPokemon.size() > 0) {
        pickablePokemon=new ArrayList<Pokemon>(allPokes);
        pickablePokemon.removeAll(area.bannedPokemon);
      }
      for (      Pokemon areaPk : inArea) {
        if (pickablePokemon.size() == 0) {
          List<Pokemon> tempPickable=noLegendaries ? new ArrayList<Pokemon>(noLegendaryList) : new ArrayList<Pokemon>(mainPokemonList);
          tempPickable.removeAll(banned);
          tempPickable.removeAll(area.bannedPokemon);
          if (tempPickable.size() == 0) {
            throw new RandomizationException("String_Node_Str");
          }
          int picked=this.random.nextInt(tempPickable.size());
          Pokemon pickedMN=tempPickable.get(picked);
          areaMap.put(areaPk,pickedMN);
        }
 else {
          int picked=this.random.nextInt(allPokes.size());
          Pokemon pickedMN=allPokes.get(picked);
          areaMap.put(areaPk,pickedMN);
          pickablePokemon.remove(pickedMN);
          if (allPokes != pickablePokemon) {
            allPokes.remove(pickedMN);
          }
          if (allPokes.size() == 0) {
            allPokes.addAll(noLegendaries ? noLegendaryList : mainPokemonList);
            allPokes.removeAll(banned);
            if (pickablePokemon != allPokes) {
              pickablePokemon.addAll(allPokes);
              pickablePokemon.removeAll(area.bannedPokemon);
            }
          }
        }
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
 else   if (typeThemed) {
    Map<Type,List<Pokemon>> cachedPokeLists=new TreeMap<Type,List<Pokemon>>();
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      List<Pokemon> possiblePokemon=null;
      int iterLoops=0;
      while (possiblePokemon == null && iterLoops < 10000) {
        Type areaTheme=randomType();
        if (!cachedPokeLists.containsKey(areaTheme)) {
          List<Pokemon> pType=pokemonOfType(areaTheme,noLegendaries);
          pType.removeAll(banned);
          cachedPokeLists.put(areaTheme,pType);
        }
        possiblePokemon=new ArrayList<Pokemon>(cachedPokeLists.get(areaTheme));
        if (area.bannedPokemon.size() > 0) {
          possiblePokemon.removeAll(area.bannedPokemon);
        }
        if (possiblePokemon.size() < inArea.size()) {
          possiblePokemon=null;
        }
        iterLoops++;
      }
      if (possiblePokemon == null) {
        throw new RandomizationException("String_Node_Str");
      }
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      for (      Pokemon areaPk : inArea) {
        int picked=this.random.nextInt(possiblePokemon.size());
        Pokemon pickedMN=possiblePokemon.get(picked);
        areaMap.put(areaPk,pickedMN);
        possiblePokemon.remove(picked);
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
 else   if (usePowerLevels) {
    List<Pokemon> allowedPokes=noLegendaries ? new ArrayList<Pokemon>(noLegendaryList) : new ArrayList<Pokemon>(mainPokemonList);
    allowedPokes.removeAll(banned);
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      List<Pokemon> usedPks=new ArrayList<Pokemon>();
      List<Pokemon> localAllowed=allowedPokes;
      if (area.bannedPokemon.size() > 0) {
        localAllowed=new ArrayList<Pokemon>(allowedPokes);
        localAllowed.removeAll(area.bannedPokemon);
      }
      for (      Pokemon areaPk : inArea) {
        Pokemon picked=pickWildPowerLvlReplacement(localAllowed,areaPk,false,usedPks);
        areaMap.put(areaPk,picked);
        usedPks.add(picked);
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
 else {
    for (    EncounterSet area : scrambledEncounters) {
      Set<Pokemon> inArea=pokemonInArea(area);
      Map<Pokemon,Pokemon> areaMap=new TreeMap<Pokemon,Pokemon>();
      for (      Pokemon areaPk : inArea) {
        Pokemon picked=noLegendaries ? randomNonLegendaryPokemon() : randomPokemon();
        while (areaMap.containsValue(picked) || banned.contains(picked) || area.bannedPokemon.contains(picked)) {
          picked=noLegendaries ? randomNonLegendaryPokemon() : randomPokemon();
        }
        areaMap.put(areaPk,picked);
      }
      for (      Encounter enc : area.encounters) {
        enc.pokemon=areaMap.get(enc.pokemon);
      }
    }
  }
  setEncounters(useTimeOfDay,currentEncounters);
}