Mapping Poker-Starting Hands to 0..1325

Started by
10 comments, last by .chicken 9 years, 7 months ago

Ok, thanks everyone, I found a quick enough solution now smile.png


So what is it?
Advertisement

Well,I guess this is what you meant by precomputing the arrays?


    static std::vector<std::vector<startingHand>> fillCardsToHand() {
        std::vector<std::vector<startingHand>> result;
        for (int i = 0; i < kNumCards; i++) {
            result.push_back(std::vector<startingHand>());
            for (int j = 0; j < kNumCards; j++) {
                result[i].push_back(i < j ? (i*(103 - i) / 2 + (j - i) - 1) : (j*(103 - j) / 2 + (i - j) - 1));
            }
        }
        return result;
    }
    static std::vector<std::pair<card, card>> fillHandsToCard() {
        std::vector<std::pair<card, card>> result;
        for (int i = 0; i < kNumHands; i++) {
            for (int k = 0; k < kNumCards; k++) {
                if ((k*(103 - k) / 2) > i) {
                    result.push_back(std::make_pair(k - 1, i - ((k - 1) * (103 - (k - 1)) / 2 - (k - 1) - 1)));
                    break;
                }
            }
        }
        return result;
    }
    static std::vector<std::vector<startingHand>> cardsToHandArray = fillCardsToHand();
    static std::vector<std::pair<card,card>> handsToCardArray = fillHandsToCard();

This topic is closed to new replies.

Advertisement