Program: 19739
Project: 19739
Buggy source:
/** 
 * This method enables agents to pick their preferred choice of food The choice is based on several factors. First of all if we deal with a free agent its choice is based only on its type (TFT, AD, AC or R). Otherwise, the agent belongs to a group it can also ask for advice. If the advice is not good enough then the agent just follows its type.
 * @param none
 * @return The chosen food for this round.
 */
@Override protected Food chooseFood(){
  List<String> members=this.getDataModel().getHuntingTeam().getMembers();
  List<Food> foodArray=new LinkedList<Food>();
  Food suggestedFood, cooperateFood, defectFood, choice;
  foodArray=this.getFoodTypes();
  cooperateFood=foodArray.get(0);
  defectFood=foodArray.get(1);
  String groupID=this.getDataModel().getGroupId();
  if (groupID != null && getConn().getGroupById(groupID).getMemberList().size() > 1) {
    suggestedFood=this.askAdvice(members);
    if (suggestedFood != null) {
      return suggestedFood;
    }
  }
switch (this.getDataModel().getAgentType()) {
case AC:
    choice=cooperateFood;
  break;
case AD:
choice=defectFood;
break;
case R:
choice=(uniformRandBoolean() ? cooperateFood : defectFood);
break;
case TFT:
Food opponentPreviousChoice=cooperateFood;
if (members.size() == 1) {
choice=cooperateFood;
return choice;
}
if (members.get(0).equals(this.getId())) {
if (getConn().getAgentById(members.get(1)) != null) {
if (getConn().getAgentById(members.get(1)).getHuntingHistory().size() != 1) {
opponentPreviousChoice=getConn().getAgentById(members.get(1)).getHuntingHistory().getValue(1);
}
}
}
 else {
if (getConn().getAgentById(members.get(0)) != null) {
if (getConn().getAgentById(members.get(0)).getHuntingHistory().size() != 1) {
opponentPreviousChoice=getConn().getAgentById(members.get(0)).getHuntingHistory().getValue(1);
}
}
}
choice=opponentPreviousChoice;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
return choice;
}

Fixed version (ground truth):
/** 
 * This method enables agents to pick their preferred choice of food The choice is based on several factors. First of all if we deal with a free agent its choice is based only on its type (TFT, AD, AC or R). Otherwise, the agent belongs to a group it can also ask for advice. If the advice is not good enough then the agent just follows its type.
 * @param none
 * @return The chosen food for this round.
 */
@Override protected Food chooseFood(){
  if (getDataModel().getHuntingTeam() == null)   return null;
  List<String> members=this.getDataModel().getHuntingTeam().getMembers();
  List<Food> foodArray=new LinkedList<Food>();
  Food suggestedFood, cooperateFood, defectFood, choice;
  foodArray=this.getFoodTypes();
  cooperateFood=foodArray.get(0);
  defectFood=foodArray.get(1);
  String groupID=this.getDataModel().getGroupId();
  if (groupID != null && getConn().getGroupById(groupID).getMemberList().size() > 1) {
    suggestedFood=this.askAdvice(members);
    if (suggestedFood != null) {
      return suggestedFood;
    }
  }
switch (this.getDataModel().getAgentType()) {
case AC:
    choice=cooperateFood;
  break;
case AD:
choice=defectFood;
break;
case R:
choice=(uniformRandBoolean() ? cooperateFood : defectFood);
break;
case TFT:
Food opponentPreviousChoice=cooperateFood;
if (members.size() == 1) {
choice=cooperateFood;
return choice;
}
if (members.get(0).equals(this.getId())) {
if (getConn().getAgentById(members.get(1)) != null) {
if (getConn().getAgentById(members.get(1)).getHuntingHistory().size() != 1) {
opponentPreviousChoice=getConn().getAgentById(members.get(1)).getHuntingHistory().getValue(1);
}
}
}
 else {
if (getConn().getAgentById(members.get(0)) != null) {
if (getConn().getAgentById(members.get(0)).getHuntingHistory().size() != 1) {
opponentPreviousChoice=getConn().getAgentById(members.get(0)).getHuntingHistory().getValue(1);
}
}
}
choice=opponentPreviousChoice;
break;
default :
throw new IllegalStateException("String_Node_Str");
}
return choice;
}