Package ise.mace.models

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


    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

   * @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

   */
  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

   * @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

    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

    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, 0.3);
      }
View Full Code Here

   */
  private 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

    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);

    //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

    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, 0.3);
      }
View Full Code Here

TOP

Related Classes of ise.mace.models.Food

Copyright © 2018 www.massapicom. 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.