Exemplo n.º 1
0
 @OPERATION
 public void getBalanceFromRestaurants() throws OperationException {
   Set<Integer> keys = restaurantTable.keySet();
   for (Integer key : keys) {
     ArrayList<ArtifactId> restaurants = restaurantTable.get(key);
     for (ArtifactId restaurant : restaurants) {
       // Double d = new Double(0);
       OpFeedbackParam<Double> d = new OpFeedbackParam<Double>();
       execLinkedOp(restaurant, "getBalance", d);
       double val = d.get();
       System.out.println("Balance for restaurant " + restaurant.getName() + " is: " + val);
       // System.out.println("Value: "+d);
     }
   }
   setPostEvaluationDone(true);
 }
  @OPERATION
  void sense() {
    OpFeedbackParam<PersonSenseData[]> people = new OpFeedbackParam<>();
    OpFeedbackParam<PoTSenseData[]> points = new OpFeedbackParam<>();
    try {
      execLinkedOp("env-link", "sense", ID, people, points);
      ObsProperty peoplep = getObsProperty("people");
      ObsProperty pointsp = getObsProperty("points");

      peoplep.updateValue(toArray(people.get()));
      pointsp.updateValue(toArray(points.get()));

    } catch (Exception e) {
      e.printStackTrace();
      failed("Sense linked operation failed", "fail", ID, e);
    }
  }
Exemplo n.º 3
0
 @OPERATION
 protected void registerAgent(OpFeedbackParam<String> wsp) {
   AgentId aid = getOpUserId();
   System.out.println("registering agent " + aid);
   super.registerAgent(wsp);
   order.add(aid);
   wsp.set("NA");
 }
Exemplo n.º 4
0
 /**
  * Operation that gives agents a linear representation of the state of the game.
  *
  * @param result
  */
 @OPERATION
 void getGameState(OpFeedbackParam<Integer[]> result) {
   Integer[] res = new Integer[9];
   for (int i = 0; i < 3; i++)
     for (int j = 0; j < 3; j++) {
       res[3 * i + j] = gameState[i][j];
     }
   result.set(res);
 }
 @OPERATION
 void randomInt(OpFeedbackParam<Integer> res, int min, int max) {
   res.set(r.nextInt(max + 1 - min) + min);
 }
 @OPERATION
 void random_int(int min, int max, OpFeedbackParam<Integer> res) {
   Random r = new Random();
   res.set(r.nextInt((max - min + 1)) + min);
 }
 @OPERATION
 void toss_coin(double prob, OpFeedbackParam<Boolean> res) {
   Random r = new Random();
   res.set(r.nextDouble() < prob);
 }