예제 #1
0
  public boolean isActionSafe(ACTIONS action, ElapsedCpuTimer elapsedTimer) {
    checkOther = true;
    int numTries = 10;
    if (!shouldCheck(2)) numTries = 1;

    StateObservation stateNext;

    for (int i = 0; i < numTries; i++) {
      if (elapsedTimer.remainingTimeMillis() < tlim1) break;
      stateNext = initialState.copy();
      stateNext.advance(action);
      if (stateNext.getGameWinner() == Types.WINNER.PLAYER_LOSES) return false;
    }

    return true;
  }
예제 #2
0
  public boolean isNilSafe(ElapsedCpuTimer elapsedTimer) {
    checkOther = true;
    int numTries = 10;
    if (!shouldCheck(2)) numTries = 1;
    ACTIONS actNil = this.getActionNil();

    StateObservation stateNext;

    for (int i = 0; i < numTries; i++) {
      if (elapsedTimer.remainingTimeMillis() < tlim1) {
        // System.out.println("-----" + i);
        break;
      }
      stateNext = initialState.copy();
      stateNext.advance(actNil);
      if (stateNext.getGameWinner() == Types.WINNER.PLAYER_LOSES) return false;
    }

    // System.out.println("-----" + 9);
    return true;
  }
예제 #3
0
  private HashMap<Integer, Integer> getMapDeathActions(ElapsedCpuTimer elapsedTimer) {
    ArrayList<ACTIONS> actions = initialState.getAvailableActions();
    int numActions = actions.size();

    HashMap<Integer, Integer> mapActionDeath = new HashMap<Integer, Integer>(10);

    StateObservation nextState;
    int numTrials = 13;
    int i, max = 0;

    for (i = 0; i < numActions; i++) {
      mapActionDeath.put(i, 0);
    }

    for (int j = 0; j < numTrials; j++) {
      if (j > max) max = j;
      for (i = 0; i < numActions; i++) {
        int tlim = tlim1;
        if (checkOther) {
          tlim = tlim2;
          checkOther = false;
        }
        if (elapsedTimer.remainingTimeMillis() < tlim) {
          // System.out.println("-----" + max);
          return mapActionDeath;
        }
        nextState = initialState.copy();
        nextState.advance(actions.get(i));
        if (nextState.isGameOver()) {
          if (nextState.getGameWinner() == Types.WINNER.PLAYER_LOSES) {
            mapActionDeath.put(i, mapActionDeath.get(i) + 1);
          }
        }
      }
    }

    // System.out.println("-----" + max);
    return mapActionDeath;
  }