int Server::runGame()

in csrc/HanabiServer.cc [228:284]


int Server::runGame(std::vector<Bot*> players, const std::vector<Card>& stackedDeck)
{
    std::cerr << "Starting game..." << std::endl;
    /* Create and initialize the bots. */
    players_ = players;
    numPlayers_ = players.size();
    const int initialHandSize = this->handSize();

    /* Initialize the piles and stones. */
    for (Color color = RED; color <= BLUE; ++color) {
        piles_[(int)color].color = color;
        piles_[(int)color].size_ = 0;
    }
    mulligansRemaining_ = NUMMULLIGANS;
    hintStonesRemaining_ = NUMHINTS;
    finalCountdown_ = 0;

    /* Shuffle the deck. */
    if (!stackedDeck.empty()) {
        deck_ = stackedDeck;
        std::reverse(deck_.begin(), deck_.end());  /* because we pull cards from the "top" (back) of the vector */
    } else {
        deck_.clear();
        for (Color color = RED; color <= BLUE; ++color) {
            for (int value = 1; value <= 5; ++value) {
                const Card card(color, value);
                const int n = card.count();
                for (int k=0; k < n; ++k) deck_.push_back(card);
            }
        }
        portable_shuffle(deck_.begin(), deck_.end(), rand_);
    }
#ifdef CARD_ID
    int id_count = 0;
    for (auto &card: deck_) {
      card.id = id_count++;
    }
#endif
    discards_.clear();

    /* Secretly draw the starting hands. */
    hands_.resize(numPlayers_);
    for (int i=0; i < numPlayers_; ++i) {
        hands_[i].clear();
        for (int k=0; k < initialHandSize; ++k) {
            hands_[i].push_back(this->draw_());
        }
    }

    /* Run the game. */
    activeCardIsObservable_ = false;
    activePlayer_ = 0;
    movesFromActivePlayer_ = -1;
    int score = this->runToCompletion();

    return score;
}