if (getDataModel().getHuntingTeam() == null) return null;
List<String> members = this.getDataModel().getHuntingTeam().getMembers();
//We assume there will only be two food sources (stags/rabbits)
List<Food> foodArray = new LinkedList<Food>();
Food suggestedFood, cooperateFood, defectFood, choice;
//Distinguish between stag (cooperate) and rabbit (defect)
foodArray = this.getFoodTypes();
cooperateFood = foodArray.get(0);
defectFood = foodArray.get(1);
String groupID = this.getDataModel().getGroupId();
//If the agent belongs to a group then it can ask for advice
if (groupID != null && getConn().getGroupById(groupID).getMemberList().size() > 1)
{
suggestedFood = this.askAdvice(members);
if (suggestedFood != null)
{
return suggestedFood;
}
}
//If the agent is not in a group or advisor didn't give a definitive answer then hunt
//according to type
switch (this.getDataModel().getAgentType())
{
//The choice is always to hunt stags
case AC:
choice = cooperateFood;
break;
//The choice is always to hunt rabbits
case AD:
choice = defectFood;
break;
// Picks a random stratergy
case R:
choice = (uniformRandBoolean() ? cooperateFood : defectFood);
break;
//If first time cooperate else imitate what your partner (opponent?) choose the previous time
case TFT:
//Get last hunting choice of opponent and act accordingly
Food opponentPreviousChoice = cooperateFood;
// TFT makes no sense in a team of 1...
if (members.size() == 1)
{
choice = cooperateFood;