Ejemplo n.º 1
0
 /**
  * Creates an agent that represents a group
  *
  * @param food Amount of food
  * @param economic Economic location
  * @param social Social location
  * @param name Name
  * @return The id of the Group-Agent
  * @see PoliticalAgentGroup
  */
 String createGroupAgent(double food, double economic, double social, String name) {
   AbstractAgent a = new PoliticalAgentGroup(food, 0, AgentType.R, economic, social, name);
   a.initialise(new EnvironmentConnector(this));
   sim.addParticipant(a.getId(), a);
   sim.activateParticipant(a.getId());
   return a.getId();
 }
Ejemplo n.º 2
0
  /**
   * Get advice for a calling {@link AbstractAgent agent} from a remote agent as the best option for
   * hunting
   *
   * @param agent The source agent
   * @param authToken The token used to verify the source agent's identification
   * @param fromAgent The agent that is to advise the source agent
   * @param agentsTeam The team that the source agent is a member of
   * @return The food that they are advised to hunt
   * @see AbstractAgent#advise(java.lang.String, ise.mace.models.HuntingTeam)
   * @see AbstractAgent#seekAvice(java.lang.String)
   * @see AbstractAgent#giveAdvice(java.lang.String, ise.mace.models.HuntingTeam)
   */
  Food seekAdvice(String agent, UUID authToken, String fromAgent, HuntingTeam agentsTeam) {
    if (authenticator.get(agent) != authToken) {
      throw new IllegalAccessError("Incorrect access credentials");
    }
    AbstractAgent a = (AbstractAgent) sim.getPlayer(fromAgent);
    AbstractAgent b = (AbstractAgent) sim.getPlayer(agent);

    String ga = a.getDataModel().getGroupId();
    String gb = b.getDataModel().getGroupId();
    if (ga == null ? gb != null : !ga.equals(gb)) {
      return null;
    }

    return a.advise(agent, agentsTeam);
  }