Package ise.mace.environment

Examples of ise.mace.environment.PublicEnvironmentConnection


    {
      return null;
    }

    ArrayList<PublicAgentDataModel> dataModels = new ArrayList<PublicAgentDataModel>();
    PublicEnvironmentConnection envConn = PublicEnvironmentConnection.getInstance();

    for (String id : geneticAgentIds)
    {
      if (null == id) continue;
      dataModels.add(envConn.getAgentById(id));
    }

    return dataModels;
  }
View Full Code Here


    data.add("------------------------------------------------");
    data.add(
            "Group Name | Current reserve \t| Amount given \t| Amount borrowed \t| Average Happiness \t| Greediness");
    SortedSet<String> active_agent_ids = sim.getactiveParticipantIdSet("group");
    Iterator<String> iter = active_agent_ids.iterator();
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();
    while (iter.hasNext())
    {
      String groupID = iter.next();
      PublicGroupDataModel dm = ec.getGroupById(groupID);
      Map<String, List<Tuple<Double, Double>>> loansGiven = PoliticalGroup.getLoansGiven(
              dm);
      double totalAmountGiven = 0;
      if (loansGiven != null)
      {
        for (String debtors : loansGiven.keySet())
        {
          //if (ec.getGroupById(debtors) == null) break;
          double amountBorrowed = 0;
          for (Tuple<Double, Double> t : loansGiven.get(debtors))
          {
            amountBorrowed += t.getKey() * (1 + t.getValue());
          }
          totalAmountGiven += amountBorrowed;
        }
      }
      Map<String, List<Tuple<Double, Double>>> loansTaken = PoliticalGroup.getLoansTaken(
              dm);
      double totalAmountTaken = 0;
      if (loansTaken != null)
      {
        for (String creditors : loansTaken.keySet())
        {
          //if (ec.getGroupById(creditors) == null) break;
          double amountBorrowed = 0;
          for (Tuple<Double, Double> t : loansTaken.get(creditors))
          {
            amountBorrowed += t.getKey() * (1 + t.getValue());
          }
          totalAmountTaken += amountBorrowed;
        }
      }
      double averageHappiness = 0;
      for (String member : dm.getMemberList())
      {
        averageHappiness += ec.getAgentById(member).getCurrentHappiness();
      }
      averageHappiness = averageHappiness / dm.getMemberList().size();
      String spaces = "                               ";
      data.add(dm.getName()
              + spaces + Math.round(dm.getCurrentReservedFood())
View Full Code Here

  }

  private void updateLoanPlayers(SortedSet<String> active_agent_ids,
          Iterator<String> itera)
  {
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();
    // Add any new groups
    while (itera.hasNext())
    {
      String id = itera.next();
      if (!p_players.containsKey(id))
      {
        if (!sim.getPlayer(id).getClass().equals(
                ec.getAllowedGroupTypes().get(1)))
        {
          p_players.put(id, (PoliticalGroup)sim.getPlayer(id));

        }
      }
View Full Code Here

  }

  private double getNumHunters()
  {
    SortedSet<String> participantIdSet = sim.getactiveParticipantIdSet("hunter");
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();
                String SpecialID = "";
                for(String group : ec.getGroups())
                   if(ec.getGroupById(group).getName().equals("Group #2"))
                       SpecialID = group;  
                if(SpecialID.equals(""))
                    return participantIdSet.size();
                else
                    return participantIdSet.size() - ec.getGroupById(SpecialID).size();
  }
View Full Code Here

    @SuppressWarnings("LeakingThisInConstructor")
    HunterPanel(PublicAgentDataModel dm)
    {
      this.dm = dm;
      PublicEnvironmentConnection Conn = PublicEnvironmentConnection.getInstance();
      String current = "Alive";
      if (!sim.isParticipantActive(dm.getId()))
      {
        current = "Dead";
      }
      else if (Conn.getGroups() != null && dm.getGroupId() != null && Conn.getGroupById(
              this.dm.getGroupId()) != null)
      {
        String Leader = "";
        //Leaders
        if (Conn.getGroupById(this.dm.getGroupId()).getPanel() != null)
        {
          for (String ldr : Conn.getGroupById(this.dm.getGroupId()).getPanel())
          {
            if (ldr.equals(dm.getId()))
            {
              Leader = " - Leader";
            }
          }
        }
        if (Conn.getGroupById(dm.getGroupId()) != null)
          current = "Alive - " + Conn.getGroupById(dm.getGroupId()).getName() + Leader;
      }
      else
      {
        current = "Alive - Free";
      }
View Full Code Here

     *   - This represents an autocracy
     *  - The values used to find standard deviation will be the average of each
     *    agent's opinion of an agent
     */
    List<Double> avg_trusts = new ArrayList<Double>(memberList.size());
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();
    if (ec == null) return 0.5;

    // Find how trusted each agent is on average
    for (String candidate : memberList)
    {
      int n = 0;
      double sum = 0;
      for (String truster : memberList)
      {
        PublicAgentDataModel dm = ec.getAgentById(truster);
        Double t = (dm == null ? null : dm.getTrust(candidate));
        if (t != null && !candidate.equals(truster))
        {
          sum += t;
          ++n;
View Full Code Here

   * @param g Graphics object
   */
  @Override
  public void paint(Graphics g)
  {
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();

    // Clear everything
    g.setColor(Color.LIGHT_GRAY);
    g.fillRect(0, 0, getWidth(), getHeight());

    // Draw social and economic axis
    Rectangle rect = g.getClipBounds();
    g.setColor(Color.YELLOW);
    g.drawLine(rect.width / 2, 0, rect.width / 2, rect.height);
    g.drawLine(0, rect.height / 2, rect.width, rect.height / 2);

    // Draw agents
    for (String group : PublicEnvironmentConnection.getInstance().getGroups())
    {
      PublicGroupDataModel dm = ec.getGroupById(group);
      double size = 2 * Math.sqrt((double)dm.size());
      logger.log(Level.INFO, "{0} [{1}] '{'{2},{3},{4}'}'", new Object[]
              {
                group,
                dm.getName(), dm.getCurrentEconomicPoisition(),
View Full Code Here

    @SuppressWarnings("LeakingThisInConstructor")
    HunterPanel(PublicAgentDataModel dm)
    {
      this.dm = dm;
      PublicEnvironmentConnection Conn = PublicEnvironmentConnection.getInstance();
      String current = "Alive";
      if (!sim.isParticipantActive(dm.getId()))
      {
        current = "Dead";
      }
      else if (Conn.getGroups() != null && dm.getGroupId() != null && Conn.getGroupById(
              this.dm.getGroupId()) != null)
      {
        String Leader = "";
        //Leaders
        if (Conn.getGroupById(this.dm.getGroupId()).getPanel() != null)
        {
          for (String ldr : Conn.getGroupById(this.dm.getGroupId()).getPanel())
          {
            if (ldr.equals(dm.getId()))
            {
              Leader = " - Leader";
            }
          }
        }
        if (Conn.getGroupById(dm.getGroupId()) != null)
          current = "Alive - " + Conn.getGroupById(dm.getGroupId()).getName() + Leader;
      }
      else
      {
        current = "Alive - Free";
      }
View Full Code Here

    data.add("Groups final score (food reserve)");
    data.add("------------------------------------------------");
    data.add(
            "Group Name | Current reserve \t| Amount given \t| Amount borrowed \t| Average Happiness \t| Greediness");
    SortedSet<String> active_agent_ids = sim.getactiveParticipantIdSet("group");
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();
                //get rid of special group
                String SpecialID = "";
                for(String group : active_agent_ids)
                   if(ec.getGroupById(group).getName().equals("Group #2"))
                       SpecialID = group;
                active_agent_ids.remove(SpecialID);  
               
    Iterator<String> iter = active_agent_ids.iterator();               
    while (iter.hasNext())
    {
      String groupID = iter.next();
      PublicGroupDataModel dm = ec.getGroupById(groupID);
      Map<String, List<Tuple<Double, Double>>> loansGiven = LoansGroup.getLoansGiven(
              dm);
      double totalAmountGiven = 0;
      if (loansGiven != null)
      {
        for (String debtors : loansGiven.keySet())
        {
          //if (ec.getGroupById(debtors) == null) break;
          double amountBorrowed = 0;
          for (Tuple<Double, Double> t : loansGiven.get(debtors))
          {
            amountBorrowed += t.getKey() * (1 + t.getValue());
          }
          totalAmountGiven += amountBorrowed;
        }
      }
      Map<String, List<Tuple<Double, Double>>> loansTaken = LoansGroup.getLoansTaken(
              dm);
      double totalAmountTaken = 0;
      if (loansTaken != null)
      {
        for (String creditors : loansTaken.keySet())
        {
          //if (ec.getGroupById(creditors) == null) break;
          double amountBorrowed = 0;
          for (Tuple<Double, Double> t : loansTaken.get(creditors))
          {
            amountBorrowed += t.getKey() * (1 + t.getValue());
          }
          totalAmountTaken += amountBorrowed;
        }
      }
      double averageHappiness = 0;
      for (String member : dm.getMemberList())
      {
        averageHappiness += ec.getAgentById(member).getCurrentHappiness();
      }
      averageHappiness = averageHappiness / dm.getMemberList().size();
      String spaces = "                               ";
      data.add(dm.getName()
              + spaces + Math.round(dm.getCurrentReservedFood())
View Full Code Here

  }

  private void updateLoanPlayers(SortedSet<String> active_agent_ids,
          Iterator<String> itera)
  {
    PublicEnvironmentConnection ec = PublicEnvironmentConnection.getInstance();
    // Add any new groups
    while (itera.hasNext())
    {
      String id = itera.next();
      if (!p_players.containsKey(id))
      {
        if (!sim.getPlayer(id).getClass().equals(
                ec.getAllowedGroupTypes().get(1)))
        {
          p_players.put(id, (LoansGroup)sim.getPlayer(id));

        }
      }
View Full Code Here

TOP

Related Classes of ise.mace.environment.PublicEnvironmentConnection

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.