void randomizeHandCards(struct gameState *testG, int thisPlayer) { int i = 1; testG->hand[thisPlayer][0] = sea_hag; for (i = 1; i < testG->handCount[thisPlayer]; ++i){ testG->hand[thisPlayer][i] = randomCard(); } }
void randomDeck(int player, int size, int kingdomCards[KINGDOM_CARDS_SIZE], struct gameState *state) { state->deckCount[player] = 0; for(int i = 0; i < size; i++){ state->deck[player][i] = randomCard(kingdomCards); state->deckCount[player]++; } }
void CardHolder::fetchCardSet(CardNumber cardsPerDraw, CardNumberArray& cardArray) { // どの種類のカードを引いたか std::unordered_map<CardNumber, bool> hasDrawnMap; // 両端を含む一様乱数 std::uniform_int_distribution<CardNumber> randomCard(0, kindOfCards_ - 1); // カードの種類が重複したら引き直す for(CardNumber i=0; i<cardsPerDraw; ++i) { CardNumber num = 0; do { num = randomCard(randGen_); } while(hasDrawnMap[num]); cardArray[i] = num; hasDrawnMap[num] = true; } return; }
// Begin a new round: save previous actions/cards, deal new cards, choose // environment's (opponent's) first action, compute observation. void KuhnPoker::reset() { // Save the previous actions/cards for use by print() m_env_previous_action = m_env_action; m_agent_previous_card = m_agent_card; m_env_previous_card = m_env_card; // Deal cards m_agent_card = randomCard(); m_env_card = m_agent_card; while(m_env_card == m_agent_card) m_env_card = randomCard(); // Choose the environment's first action. Bet with a certain probability // on jack and king, pass on queen. if(m_env_card == oJack) m_env_action = rand01() < cBetProbJack ? aBet : aPass; else if(m_env_card == oQueen) m_env_action = aPass; // Always pass on queen else if(m_env_card == oKing) m_env_action = rand01() < cBetProbKing ? aBet : aPass; // Compute observation: agent-card + environment-bet-status m_observation = m_agent_card + (m_env_action == aPass ? oPass : oBet); }
void randomizePlayedCards(struct gameState *testG) { int i = 0; for (i = 0; i < testG->playedCardCount; ++i){ testG->playedCards[i] = randomCard(); } }
void randomizeDeckCards(struct gameState *testG, int thisPlayer) { int i = 0; for (i = 0; i < testG->deckCount[thisPlayer]; ++i){ testG->deck[thisPlayer][i] = randomCard(); } }