Program: 19706
Project: 19706
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(){
  if (getDataModel().getHuntingTeam() == null)   return null;
  List<String> members=this.getDataModel().getHuntingTeam().getMembers();
  List<Food> foodArray=new LinkedList<Food>();
  Food cooperateFood, defectFood, choice;
  foodArray=this.getFoodTypes();
  cooperateFood=foodArray.get(0);
  defectFood=foodArray.get(1);
  String groupID=this.getDataModel().getGroupId();
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 cooperateFood, defectFood, choice;
  foodArray=this.getFoodTypes();
  cooperateFood=foodArray.get(0);
  defectFood=foodArray.get(1);
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;
}