Package it.unito.di.artifact

Examples of it.unito.di.artifact.RoleId


 
  // ROLES OPERATIONS
 
  @OPERATION
  public void cfp(String task) {
    RoleId initiator = getRoleIdByPlayerName(getOpUserName());
    this.defineObsProperty("task", task, initiator.getCanonicalName());
    RoleId dest = new RoleId(PARTICIPANT_ROLE);
     try {     
      createAllCommitments(new Commitment(initiator, dest, "propose", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
      assertFact(new Fact("cfp", initiator, task));
      logger.trace("OPERATION PERFORMED: CFP by "+initiator.getPlayerAgentId().getGlobalId());
View Full Code Here


    }
  }
 
  @OPERATION
  public void accept(String prop) {
    RoleId participant = getRoleIdByRoleCanonicalName(prop);
//    send(accept);
    // VERSIONE CON SIGNAL PARTICOLARE, CHE RICHIEDE QUINDI LE REJECT A TUTTI GLI ALTRI
    //signal(participant.getPlayerAgentId(), "accept");
    // VERSIONE CON PUBBLICAZIONE DI CHI HA VINTO
    defineObsProperty("accept", participant.getCanonicalName());
    try {
      assertFact(new Fact("accept",participant.getPlayerAgentId()));
     
      //**** DEBUG: CAMBIO STATO DI VITA A COMMITMENT GIUSTO, SARA' IL SOCIAL STATE CHE DOVRA' GESTIRLO
      for (Commitment com : interactionState.retrieveAllCommitments()) {
        if (com.getAntecedent().equals(new Fact("accept"))) {
            removeObsPropertyByTemplate("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
View Full Code Here

//  }
 
  @OPERATION
  public void propose(String prop, int cost, String init) {
    Proposal p = new Proposal(prop, cost);   
    RoleId participant = getRoleIdByPlayerName(getOpUserName());
    RoleId initiator = getRoleIdByRoleCanonicalName(init);
    p.setRoleId(participant);
    // VERSIONE CON SIGNAL PARTICOLARE
    // signal(initiator.getPlayerAgentId(), "proposal", p.getProposalContent(), p.getCost(), participant.getCanonicalName());
    defineObsProperty("proposal", p.getProposalContent(), p.getCost(), participant.getCanonicalName());
     try {     
      createCommitment(new Commitment(participant, initiator, "accept", new CompositeExpression(
          LogicalOperatorType.OR, new Fact("done"), new Fact("failure"))));
      assertFact(new Fact("propose", participant, prop));
     
      //**** DEBUG: CAMBIO STATO DI VITA A COMMITMENT GIUSTO, SARA' IL SOCIAL STATE CHE DOVRA' GESTIRLO
      for (Commitment com : interactionState.retrieveCommitmentsByCreditorRoleId(participant)) {
        if (com.getAntecedent().equals(new Fact("propose")) && com.getLifeCycleStatus().equals(LifeCycleState.CONDITIONAL)) {
            removeObsPropertyByTemplate("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
            com.setStatus(LifeCycleState.DETACHED);
            com.setAntecedent(new Fact("true"));
            actualProposals++;
            defineObsProperty("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
           
        }
      }
      if (actualProposals == numberMaxProposals) {
        RoleId groupParticipant = new RoleId(PARTICIPANT_ROLE);
        createCommitment(new Commitment(initiator, groupParticipant, new CompositeExpression(
            LogicalOperatorType.OR, new Fact("accept"), new Fact("reject"))));
//        defineObsProperty("cc", initiator.getCanonicalName(), "GroupParticipant",
//            "true", "(accept OR reject)", "DETACHED");
       
View Full Code Here

    }
  }
 
  @OPERATION
  public void done(String result, String init) {
    RoleId rolePart = getRoleIdByPlayerName(getOpUserName());
    //signal(initiator.getPlayerAgentId(), "done", result);
    defineObsProperty("done", result);
    long now = new Date().getTime();
    log("TIME ELAPSED: "+((now-millis)/1000));
    try {
View Full Code Here

    }
  }
 
  @OPERATION
  public void failure(String init) {
    RoleId rolePart = getRoleIdByPlayerName(getOpUserName());
    //signal(initiator.getPlayerAgentId(), "done", result);
    defineObsProperty("failure", rolePart.getCanonicalName());
    long now = new Date().getTime();
    log("TIME ELAPSED: "+((now-millis)/1000));
    try {
      for (Commitment com : interactionState.retrieveAllCommitments()) {
        if (com.getConsequent().equals(new CompositeExpression(LogicalOperatorType.OR, new Fact("done"), new Fact("failure")))
                && com.getDebtor().equals(rolePart)) {
            removeObsPropertyByTemplate("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
            com.setStatus(LifeCycleState.DISCHARGED);
            defineObsProperty("cc", com.getDebtor().getCanonicalName(), com.getCreditor().getCanonicalName(),
                com.getAntecedent().toString(), com.getConsequent().toString(), com.getLifeCycleStatus().toString());
        }
      }
     
      assertFact(new Fact("failure", rolePart.getCanonicalName()));
      logger.trace("OPERATION PERFORMED: FAILURE by "+getOpUserName());
    } catch (MissingOperandException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (WrongOperandsNumberException e) {
View Full Code Here

TOP

Related Classes of it.unito.di.artifact.RoleId

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.