Examples of Food


Examples of ise.mace.models.Food

              authCode);
  }

  private void doHuntTurn()
  {
    Food toHunt = chooseFood();

    if (toHunt == null)
    {
      logger.log(Level.WARNING, "Agent {0} did not pick a food to hunt",
              dm.getName());
View Full Code Here

Examples of ise.mace.models.Food

   * @param agentsTeam The team are part of
   * @return What food you want to tell them to hunt
   */
  public Food advise(String agent, HuntingTeam agentsTeam)
  {
    Food advice = giveAdvice(agent, agentsTeam);
    dm.gaveAdvice(agent, advice);
    return advice;
  }
View Full Code Here

Examples of ise.mace.models.Food

  @Override
  protected Food chooseFood()
  {
    HuntingTeam team = this.getDataModel().getHuntingTeam();
    int teamSize = (team != null ? team.getMembers().size() : 1);
    Food bestSoFar = null;

    for (Food noms : getConn().availableFoods())
    {
      if (noms.getHuntersRequired() <= teamSize)
      {
        if (bestSoFar == null)
        {
          bestSoFar = noms;
        }
        else
        {
          if (noms.getNutrition() > bestSoFar.getNutrition())
          {
            bestSoFar = noms;
          }
        }
      }
View Full Code Here

Examples of ise.mace.models.Food

    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
    //Note that in the askAdvice method we examine if an agent has a trust entry for its current opponent
    //If it does then we don't ask for advice since it is not neccessary (asking for advice costs food).
    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;
View Full Code Here

Examples of ise.mace.models.Food

      return null;
    }

    //We assume there will only be two food sources (stags/rabbits)
    List<Food> foodArray = new LinkedList<Food>();
    Food cooperateFood, defectFood, choice;

    //Distinguish between stag (cooperate) and rabbit (defect)
    foodArray = this.getFoodTypes();
    cooperateFood = foodArray.get(0);
    defectFood = foodArray.get(1);
View Full Code Here

Examples of ise.mace.models.Food

    String opponentID;
    Map<String, Double> newTrustValue = new HashMap<String, Double>();
    double trust;

    //get what this agent has chosen to hunt in this round
    Food lastHunted = this.getDataModel().getLastHunted();

    //Get the members of the hunting team
    if (this.getDataModel().getHuntingTeam() == null) return null;
    List<String> members = this.getDataModel().getHuntingTeam().getMembers();

    //If agent didn't go hunting or has no team pair then do nothing
    if ((lastHunted == null) || (members.size() < 2)) return null;

    //Find out agent's opponent ID
    if (members.get(0).equals(this.getId()))
    {
      opponentID = members.get(1);

    }
    else
    {
      opponentID = members.get(0);

    }

    //Get agent's trust value for this particular opponent
    //If there is no entry initialise it
    if (this.getDataModel().getTrust(opponentID) != null)
    {
      trust = this.getDataModel().getTrust(opponentID);
    }
    else
    {
      trust = 0.1;
    }

    //If agent hunted stag then check what the opponent did. If betrayed decrease trust
    // otherwise increase it. If the agent hunted rabbit no change in trust
    if (lastHunted.getName().equals("Stag"))
    {
      if (foodHunted == 0) //Agent has been betrayed
      {
        trust = scale(trust, -1, this.uniformRand());
      }
View Full Code Here

Examples of ise.mace.models.Food

   * @param none
   * @return The suggested food type
   */
  private Food askAdvice(List<String> members)
  {
    Food suggestedFood = null;
    String opponentID = null;

    //If the agent has no pair then no advice
    if (members.size() == 1) return null;

View Full Code Here

Examples of ise.mace.models.Food

   */
  protected List<Food> getFoodTypes()
  {
    List<Food> foodArray = new LinkedList<Food>();
    List<Food> foodList = new LinkedList<Food>();
    Food cooperateFood, defectFood;

    //Stores the two sources in an array
    for (Food noms : getConn().availableFoods())
    {
      foodArray.add(noms);
View Full Code Here

Examples of ise.mace.models.Food

   * @see Food
   */
  protected final void addFood(String name, double nutrition,
          int huntersRequired)
  {
    Food f = new Food(name, nutrition, huntersRequired);
    this.foods.put(f.getId().toString(), f);
  }
View Full Code Here

Examples of ise.mace.models.Food

    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 cooperateFood, defectFood, choice;

    //Distinguish between stag (cooperate) and rabbit (defect)
    foodArray = this.getFoodTypes();
    cooperateFood = foodArray.get(0);
    defectFood = foodArray.get(1);

    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;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.