std::vector legalActions()

in simple_game/simple_hanabi.h [227:264]


  std::vector<rela::LegalAction> legalActions() const override {
    if (terminated())
      return {};

    if (allCards_.empty()) {
      // Before random. We just consider a few possible cases.
      return rela::utils::intSeq2intStrSeq(
          rela::utils::getIncSeq(options_.seeds.size()));
    }

    std::vector<Action> actions;
    if (hints_ > 0) {
      for (int i = 0; i < options_.numPlayer; ++i) {
        // Cannot hint self.
        if (i == currPlayer_ - 1)
          continue;
        for (int j = 0; j < options_.numHold; ++j) {
          if (hands_[i][j].valid()) {
            actions.emplace_back(Action::genHintAction(SUIT, i + 1, j));
            actions.emplace_back(Action::genHintAction(RANK, i + 1, j));
          }
        }
      }
    }

    for (int j = 0; j < options_.numHold; ++j) {
      if (hands_[currPlayer_ - 1][j].valid()) {
        actions.emplace_back(Action::genPlayAction(j));
        actions.emplace_back(Action::genDiscardAction(j));
      }
    }

    std::vector<rela::LegalAction> res;
    for (const auto& act : actions) {
      res.emplace_back(parser_.encode(act), act.info());
    }
    return res;
  }