Exemple #1
0
  public static POMDPState getNewState(Domain d) {
    POMDPState s = new POMDPState();

    ObjectClass doorClass = d.getObjectClass(Names.CLASS_DOOR);
    ObjectClass indexerClass = d.getObjectClass(Names.CLASS_INDEXER);

    ObjectInstance indexer = new ObjectInstance(indexerClass, Names.OBJ_INDEXER);
    indexer.setValue(Names.ATTR_INDEX, 0);
    s.addObject(indexer);

    ObjectInstance leftDoor = new ObjectInstance(doorClass, Names.OBJ_LEFT_DOOR);
    ObjectInstance rightDoor = new ObjectInstance(doorClass, Names.OBJ_RIGHT_DOOR);

    leftDoor.setValue(Names.ATTR_POSITION, Names.LEFT);
    rightDoor.setValue(Names.ATTR_POSITION, Names.RIGHT);

    boolean doorChoice = new java.util.Random().nextBoolean();
    leftDoor.setValue(Names.ATTR_TIGERNESS, doorChoice ? 0 : 1);
    rightDoor.setValue(Names.ATTR_TIGERNESS, doorChoice ? 1 : 0);

    s.addObject(leftDoor);

    s.addObject(rightDoor);

    return s;
  }
Exemple #2
0
  public static Observation makeObservationFor(POMDPDomain d, GroundedAction a, POMDPState s) {
    ObjectInstance indexer = s.getObject(Names.OBJ_INDEXER);
    int index = indexer.getDiscValForAttribute(Names.ATTR_INDEX);

    if (index == iterations) {
      return d.getObservation(Names.OBS_COMPLETE);
    }

    ObjectInstance leftDoor = s.getObject(Names.OBJ_LEFT_DOOR);
    ObjectInstance rightDoor = s.getObject(Names.OBJ_RIGHT_DOOR);

    int leftDoorTiger = leftDoor.getDiscValForAttribute(Names.ATTR_TIGERNESS);
    java.util.Random random = new java.util.Random();

    if (a.action.getName().equals(Names.ACTION_LISTEN)) {

      Observation left =
          d.getObservation(Names.OBS_LEFT_DOOR + random.nextInt(observationsPerState));
      Observation right =
          d.getObservation(Names.OBS_RIGHT_DOOR + random.nextInt(observationsPerState));

      if (leftDoorTiger == 1) {
        return random.nextDouble() < 1 - noise ? left : right;
      } else {
        return random.nextDouble() < 1 - noise ? right : left;
      }
    } else {
      return d.getObservation(Names.OBS_NULL);
    }
  }
Exemple #3
0
    @Override
    public State performActionHelper(State st, String[] params) {
      POMDPState ps = new POMDPState(st);

      int index = ps.getObject(Names.OBJ_INDEXER).getDiscValForAttribute(Names.ATTR_INDEX);
      ps.getObject(Names.OBJ_INDEXER).setValue(Names.ATTR_INDEX, index + 1);

      boolean doorChoice = new java.util.Random().nextBoolean();
      ps.getObject(Names.OBJ_LEFT_DOOR).setValue(Names.ATTR_TIGERNESS, doorChoice ? 0 : 1);
      ps.getObject(Names.OBJ_RIGHT_DOOR).setValue(Names.ATTR_TIGERNESS, doorChoice ? 1 : 0);

      return ps;
    }