Program: 173777
Project: 173777
Buggy source:
/** 
 * Create a list of certificates that a player may buy in a Stock Round, taking all rules into account.
 * @return List of buyable certificates.
 */
@Override public void setBuyableCerts(){
  if (!mayCurrentPlayerBuyAnything())   return;
  List<PublicCertificateI> certs;
  PublicCertificateI cert;
  PublicCompanyI comp;
  StockSpaceI stockSpace;
  Portfolio from;
  int price;
  int number;
  boolean mustMergeMinor=!phase5Reached;
  List<PublicCompanyI> minors=null;
  List<City> freeStations=null;
  if (mustMergeMinor) {
    minors=new ArrayList<PublicCompanyI>();
    for (    PublicCertificateI c : getCurrentPlayer().getPortfolio().getCertificates()) {
      if (c.getCompany().getTypeName().equalsIgnoreCase("String_Node_Str")) {
        minors.add(c.getCompany());
      }
    }
  }
 else {
    freeStations=new ArrayList<City>();
    MapManager map=gameManager.getMapManager();
    for (    City city : map.getCurrentStations()) {
      if (city.getSlots() > city.getTokens().size()) {
        freeStations.add(city);
      }
    }
  }
  int playerCash=currentPlayer.getCash();
  PublicCompanyI companyBoughtThisTurn=(PublicCompanyI)companyBoughtThisTurnWrapper.getObject();
  if (companyBoughtThisTurn == null) {
    from=ipo;
    Map<String,List<PublicCertificateI>> map=from.getCertsPerCompanyMap();
    int shares;
    for (    String compName : map.keySet()) {
      certs=map.get(compName);
      if (certs == null || certs.isEmpty())       continue;
      cert=certs.get(0);
      comp=cert.getCompany();
      if (isSaleRecorded(currentPlayer,comp))       continue;
      if (maxAllowedNumberOfSharesToBuy(currentPlayer,comp,cert.getShare()) < 1)       continue;
      shares=cert.getShares();
      if (!comp.hasStarted()) {
        if (mustMergeMinor) {
          if (minors.isEmpty())           continue;
        }
 else {
          if (freeStations.isEmpty())           continue;
        }
        List<Integer> startPrices=new ArrayList<Integer>();
        for (        int startPrice : stockMarket.getStartPrices()) {
          if (startPrice * shares <= playerCash) {
            startPrices.add(startPrice);
          }
        }
        if (startPrices.size() > 0) {
          int[] prices=new int[startPrices.size()];
          Arrays.sort(prices);
          for (int i=0; i < prices.length; i++) {
            prices[i]=startPrices.get(i);
          }
          StartCompany_18EU action=new StartCompany_18EU(cert,prices);
          if (mustMergeMinor) {
            action.setMinorsToMerge(minors);
          }
 else {
            action.setAvailableHomeStations(freeStations);
          }
          possibleActions.add(action);
        }
      }
 else       if (comp.getMarketPrice() <= playerCash) {
        possibleActions.add(new BuyCertificate(cert,from,comp.getMarketPrice()));
      }
    }
  }
  from=pool;
  Map<String,List<PublicCertificateI>> map=from.getCertsPerCompanyMap();
  for (  String compName : map.keySet()) {
    certs=map.get(compName);
    if (certs == null || certs.isEmpty())     continue;
    cert=certs.get(0);
    comp=cert.getCompany();
    if (isSaleRecorded(currentPlayer,comp))     continue;
    if (maxAllowedNumberOfSharesToBuy(currentPlayer,comp,cert.getShare()) < 1)     continue;
    price=comp.getMarketPrice();
    if (companyBoughtThisTurn != null) {
      continue;
    }
    while (playerCash < price)     continue;
    possibleActions.add(new BuyCertificate(cert,from,price,1));
  }
  if (gameManager.canAnyCompanyHoldShares()) {
    for (    PublicCompanyI company : companyManager.getAllPublicCompanies()) {
      certs=company.getPortfolio().getCertificatesPerCompany(company.getName());
      if (certs == null || certs.isEmpty())       continue;
      cert=certs.get(0);
      if (isSaleRecorded(currentPlayer,company))       continue;
      if (!mayPlayerBuyCompanyShare(currentPlayer,company,1))       continue;
      if (maxAllowedNumberOfSharesToBuy(currentPlayer,company,certs.get(0).getShare()) < 1)       continue;
      stockSpace=company.getCurrentSpace();
      if (!stockSpace.isNoCertLimit() && !mayPlayerBuyCertificate(currentPlayer,company,1))       continue;
      if (company.getMarketPrice() <= playerCash) {
        possibleActions.add(new BuyCertificate(cert,company.getPortfolio(),company.getMarketPrice()));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Create a list of certificates that a player may buy in a Stock Round, taking all rules into account.
 * @return List of buyable certificates.
 */
@Override public void setBuyableCerts(){
  if (!mayCurrentPlayerBuyAnything())   return;
  List<PublicCertificateI> certs;
  PublicCertificateI cert;
  PublicCompanyI comp;
  StockSpaceI stockSpace;
  Portfolio from;
  int price;
  int number;
  boolean mustMergeMinor=!phase5Reached;
  List<PublicCompanyI> minors=null;
  List<City> freeStations=null;
  if (mustMergeMinor) {
    minors=new ArrayList<PublicCompanyI>();
    for (    PublicCertificateI c : getCurrentPlayer().getPortfolio().getCertificates()) {
      if (c.getCompany().getTypeName().equalsIgnoreCase("String_Node_Str")) {
        minors.add(c.getCompany());
      }
    }
  }
 else {
    freeStations=new ArrayList<City>();
    MapManager map=gameManager.getMapManager();
    for (    City city : map.getCurrentStations()) {
      if (city.getSlots() > city.getTokens().size()) {
        freeStations.add(city);
      }
    }
  }
  int playerCash=currentPlayer.getCash();
  PublicCompanyI companyBoughtThisTurn=(PublicCompanyI)companyBoughtThisTurnWrapper.getObject();
  if (companyBoughtThisTurn == null) {
    from=ipo;
    Map<String,List<PublicCertificateI>> map=from.getCertsPerCompanyMap();
    int shares;
    for (    String compName : map.keySet()) {
      certs=map.get(compName);
      if (certs == null || certs.isEmpty())       continue;
      cert=certs.get(0);
      comp=cert.getCompany();
      if (isSaleRecorded(currentPlayer,comp))       continue;
      if (maxAllowedNumberOfSharesToBuy(currentPlayer,comp,cert.getShare()) < 1)       continue;
      shares=cert.getShares();
      if (!comp.hasStarted()) {
        if (mustMergeMinor) {
          if (minors.isEmpty())           continue;
        }
 else {
          if (freeStations.isEmpty())           continue;
        }
        List<Integer> startPrices=new ArrayList<Integer>();
        for (        int startPrice : stockMarket.getStartPrices()) {
          if (startPrice * shares <= playerCash) {
            startPrices.add(startPrice);
          }
        }
        if (startPrices.size() > 0) {
          int[] prices=new int[startPrices.size()];
          Arrays.sort(prices);
          for (int i=0; i < prices.length; i++) {
            prices[i]=startPrices.get(i);
          }
          StartCompany_18EU action=new StartCompany_18EU(cert,prices);
          if (mustMergeMinor) {
            action.setMinorsToMerge(minors);
          }
 else {
            action.setAvailableHomeStations(freeStations);
          }
          possibleActions.add(action);
        }
      }
 else       if (comp.getMarketPrice() <= playerCash) {
        possibleActions.add(new BuyCertificate(cert,from,comp.getMarketPrice()));
      }
    }
  }
  from=pool;
  Map<String,List<PublicCertificateI>> map=from.getCertsPerCompanyMap();
  for (  String compName : map.keySet()) {
    certs=map.get(compName);
    if (certs == null || certs.isEmpty())     continue;
    cert=certs.get(0);
    comp=cert.getCompany();
    if (isSaleRecorded(currentPlayer,comp))     continue;
    if (maxAllowedNumberOfSharesToBuy(currentPlayer,comp,cert.getShare()) < 1)     continue;
    price=comp.getMarketPrice();
    if (companyBoughtThisTurn != null) {
      continue;
    }
    if (playerCash < price)     continue;
    possibleActions.add(new BuyCertificate(cert,from,price,1));
  }
  if (gameManager.canAnyCompanyHoldShares()) {
    for (    PublicCompanyI company : companyManager.getAllPublicCompanies()) {
      certs=company.getPortfolio().getCertificatesPerCompany(company.getName());
      if (certs == null || certs.isEmpty())       continue;
      cert=certs.get(0);
      if (isSaleRecorded(currentPlayer,company))       continue;
      if (!mayPlayerBuyCompanyShare(currentPlayer,company,1))       continue;
      if (maxAllowedNumberOfSharesToBuy(currentPlayer,company,certs.get(0).getShare()) < 1)       continue;
      stockSpace=company.getCurrentSpace();
      if (!stockSpace.isNoCertLimit() && !mayPlayerBuyCertificate(currentPlayer,company,1))       continue;
      if (company.getMarketPrice() <= playerCash) {
        possibleActions.add(new BuyCertificate(cert,company.getPortfolio(),company.getMarketPrice()));
      }
    }
  }
}