Examples of Food


Examples of com.trevor.king.Snake.entities.Food

        default:
            key.update();

            if (food == null) {
                Random r = new Random();
                food = new Food(screen, r.nextInt(WIDTH - Food.SIZE), r.nextInt(HEIGHT - Food.SIZE));
            }

            bg.update();
            snake.update();
            food.update();
View Full Code Here

Examples of de.peacei.gae.foodsupplier.data.Food

                    match = keyWord.charAt(0) == foodConfig.keyword.charAt(0);
                  } else {
                    match = keyWord.equals(foodConfig.keyword);
                  }
                  if (match) {
                    food[i] = new Food(foodConfig.label, description, type, extra);
                    break;
                  }
                }
        }
      } catch(Exception e) {
View Full Code Here

Examples of de.peacei.gae.foodsupplier.data.Food

        menuJsonObj.put(MENU_KEY, KeyFactory.keyToString(menu.getKey()));
       
        JSONArray foodsJsonArr = new JSONArray();
        Iterator<Food> foodIter = menu.getFoods().iterator();
        while (foodIter.hasNext()) {
          Food food = foodIter.next();
         
          JSONObject foodJsonObj = new JSONObject();
          foodJsonObj.put(FOOD_TITLE, food.getTitle());
          foodJsonObj.put(FOOD_DESC, food.getDescription());
          foodJsonObj.put(FOOD_TYPE, food.getType());
          foodJsonObj.put(FOOD_EXTRA, food.getExtra());
          foodJsonObj.put(FOOD_STUDENT_PRICE, food.getStudentPrice());
          foodJsonObj.put(FOOD_STAFF_PRICE, food.getStaffPrice());
         
          foodsJsonArr.put(foodJsonObj);
        }
        menuJsonObj.put(MENU_FOODS, foodsJsonArr);
       
View Full Code Here

Examples of games.stendhal.server.entity.item.Food

   * @param corpse
   *            The corpse on which to put the meat
   */
  @Override
  protected void dropItemsOn(final Corpse corpse) {
    final Food food = (Food) SingletonRepository.getEntityManager().getItem("meat");
    food.setQuantity(getWeight() / 10 + 1);
    corpse.add(food);
  }
View Full Code Here

Examples of ise.mace.models.Food

    this.randomSeed = seed;
  }

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

    AgentType group_type = null;

    //Each group must have a representative in the special group. If this
    //doesn't happen then something wrong is going on!
    if (getConn().getGroupById(this.getDataModel().getName()) == null)
    {
      System.out.println(
              "CANNOT HAPPEN: This Special Agent-Group: " + this.getId() + " [" + this.getDataModel().getName() + "] : is not representing a Group");
      return null;
    }
    else
    {
      //The special agent will follow the strategy decided by the panel of the group it represents
      group_type = this.getConn().getGroupById(this.getDataModel().getName()).getGroupStrategy();
      this.getDataModel().setAgentType(group_type);

      //If the group didn't make any decision (maybe anarchists) then do nothing.
      if (group_type == null)
      {
        //return null;
        group_type = AgentType.NOSTRATEGY;
        return null;
      }
      else
        System.out.println(
                "Type for Agent-Group [" + this.getDataModel().getName() + "] : " + group_type);
    }
    switch (group_type) /////THE0 ADDED
    {
      //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, 0.3);
      }
View Full Code Here

Examples of ise.mace.models.Food

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

Examples of ise.mace.models.Food

    List<String> members = this.getDataModel().getHuntingTeam().getMembers();
    int teamSize = members.size();
    PublicAgentDataModel player = this.getDataModel();
    PublicAgentDataModel opponent = null;
    Food stag = this.getFoodTypes().get(0);
    Food hare = this.getFoodTypes().get(1);

    if (teamSize > 1)
    {
      int oppIdx = (members.get(0).equals(this.getId())) ? 1 : 0;
      opponent = getConn().getAgentById(members.get(oppIdx));
    }

    boolean hasOpponent = (null != opponent);
    History<Food> opponentHuntingHistory = null;
    boolean opponentLastHuntStag = false;
    double opponentStagStrategy = 0;
    if (hasOpponent)
    {
      opponentHuntingHistory = opponent.getHuntingHistory();

      if (null != opponentHuntingHistory &&
        opponentHuntingHistory.size() > 1)
      {
        Food opponentLastHunt = opponentHuntingHistory.getValue(1);
        opponentLastHuntStag = stag.equals(opponentLastHunt);

        for (int i = 0; i < opponentHuntingHistory.size(); i++)
        {
          Food opponentFood = opponentHuntingHistory.getValue(i);
          if (stag.equals(opponentFood))
          {
            opponentStagStrategy++;
          }
        }
        opponentStagStrategy /= (double)opponentHuntingHistory.size();
      }
    }

    String groupId = player.getGroupId();
    boolean hasGroup = false;
    if (null != groupId &&
      getConn().getGroupById(groupId).getMemberList().size() > 1)
    {
      hasGroup = true;
    }
    boolean suggestedStag = false;
    if (hasGroup)
    {
      String mostTrusted = null;
      double maxTrust = 0;
      for (String member : members)
      {
        Double trust = player.getTrust(member);
        if (null == trust) continue;
        double curTrust = trust.doubleValue();
        if (curTrust < maxTrust) continue;
        maxTrust = trust;
        mostTrusted = member;
      }
      if (null != mostTrusted)
      {
        Food suggested = this.seekAvice(mostTrusted);
        suggestedStag = stag.equals(suggested);
      }
    }

    double happiness = .5;
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.