0

I am currently trying to rewrite this github repo: https://github.com/dickreuter/PokerEquityCalculator. Specifically I want it to calculate equity for ranges against ranges. There are two main files: Scoring.h and Scoring.cpp.

Scoring.h

//cppimport
#pragma once

#include <set>
#include <string>
#include <vector>


using CardsWithTableCombined = std::set<std::string>;
using Score = std::vector<std::tuple<int, int>>;

bool eval_best_hand(const std::vector<CardsWithTableCombined>&);
std::tuple< std::vector<int>, std::vector<int>, std::string> calc_score(const CardsWithTableCombined&);

__declspec(dllexport) double montecarlo(const std::set<std::string>&, const std::set<std::string>&, const int, const int);


template<typename T>
std::vector<T> slice(std::vector<T> const& v, int m, int n)  //THIS CAUSES THE ERROR
{
    if (m > v.size())
        m = v.size();
    if (n > v.size())
        n = v.size();
    auto first = v.cbegin() + m;
    auto last = v.cbegin() + n;  // ending index needs to be n=x+1

    std::vector<T> vec(first, last);
    return vec;
}




typedef std::set<std::string> CardsWithTableCombined;

struct Hand {
    Hand() = default;

    Hand(std::set<std::string> cards) : cards(std::move(cards)) {}

    std::set<std::string> cards;

    void insert(const std::string& card) {
        cards.insert(card);
    }

    void insert_hand(const Hand& hand) {
        for (const std::string& card : hand.cards)
            cards.insert(card);
    }

    [[nodiscard]] auto begin() const { return cards.begin(); }

    [[nodiscard]] auto end() const { return cards.end(); }
};

class Deck {
private:
    std::string ranks = "23456789TJQKA";
    std::string suits = "CDHS";
    Hand my_cards;
    std::set<std::string> remaining_cards_tmp;
    std::set<std::string> remaining_cards;
    std::set<std::string> cards_on_table;
    std::set<std::string> opponents_hole;
    void print_set(const std::set<std::string>& set);
public:
    std::set<std::string> full_deck;

    std::vector<Hand> player_hands;

    Deck();

    void distribute_cards(int number_of_players, const std::set<std::string>& opponents_hole);

    void remove_visible_cards(const Hand& my_cards_, const std::set<std::string>& cards_on_table);
    
    std::vector<CardsWithTableCombined> get_cards_combined();
};

Scoring.cpp

//cppimport

/*
<%
setup_pybind11(cfg)
%>
*/
#include "Scoring.h"

#include <array>
#include <vector>
#include <iostream>
#include <tuple>
#include <algorithm>

#include <iostream>
#include <algorithm>
#include <random>
#include <iterator>
#include <set>

#include <pybind11/pybind11.h>

#include <pybind11/stl.h>
#include <pybind11/complex.h>
#include <pybind11/functional.h>
#include <pybind11/chrono.h>

using namespace std;


namespace py = pybind11;
using namespace pybind11::literals;


PYBIND11_MODULE(Scoring, m) {
    m.def("montecarlo", &montecarlo);
}


namespace
{
    constexpr auto x = std::array<int, 4>{2, 2, 2, 1};
}

bool eval_best_hand(const std::vector<CardsWithTableCombined>& all_cards_with_table_combined)
// returns true if first player has best hand
{
    std::vector<std::tuple< std::vector<int>, std::vector<int>, std::string>> all_players_score;
    std::vector<std::tuple< std::vector<int>, std::vector<int>, std::string>>  all_players_score_original;
    bool best_hand;

    for (const auto& cards_with_table : all_cards_with_table_combined)
    {
        auto result = calc_score(cards_with_table);
        all_players_score.emplace_back(result);
    }
    all_players_score_original = all_players_score;

    std::sort(all_players_score.begin(), all_players_score.end(), std::greater<>());
    if (all_players_score[0] == all_players_score_original[0])
        best_hand = true; // first player is best hand
    else
        best_hand = false; // different player is best hand

    return best_hand;
}

Score get_rcounts(const CardsWithTableCombined& all_cards_with_table_combined,
    std::vector<std::size_t> available_ranks,
    const std::string original_ranks) {
    //do something
}

std::tuple< std::vector<int>, std::vector<int>, std::string> calc_score(const CardsWithTableCombined& all_cards_with_table_combined) {
    const std::string original_ranks = "23456789TJQKA";
    const std::vector<std::string> original_suits{ "C","D","H","S" };
    std::vector<std::size_t> available_ranks;
    std::vector<std::string> available_suits;
    std::vector<int> score;
    std::vector<int> card_ranks;
    std::vector<int> sorted_card_ranks;
    std::string hand_type;
    bool flush = false;
    bool straight = false;

    Score rcounts;
    std::vector<std::tuple<int, std::string>> rsuits;

    rcounts = get_rcounts(all_cards_with_table_combined, available_ranks, original_ranks);

    // sort tuple and split into score and card ranks
    std::sort(rcounts.begin(), rcounts.end(), std::greater<std::tuple<int, int>>());
    for (auto it = std::make_move_iterator(rcounts.begin()),
        end = std::make_move_iterator(rcounts.end()); it != end; ++it)
    {
        score.push_back(std::get<0>(*it));  // amount of occurrences
        card_ranks.push_back(std::get<1>(*it));  // ranks of individual cards
    }

    bool potential_threeofakind = score[0] == 3;
    bool potential_twopair = score == std::vector<int> {2, 2, 1, 1, 1};
    bool potential_pair = score == std::vector<int> {2, 1, 1, 1, 1, 1};

    auto sub_score2 = slice(score, 0, 2);
    auto sub_score4 = slice(score, 0, 5);
    auto sub_score0 = slice(score, 0, 0);
    // # fullhouse(three of a kind and pair, or two three of a kind)
    if (sub_score2 == std::vector<int> {3, 2} || sub_score2 == std::vector<int> {3, 3}) {
        // make adjustment
        card_ranks = slice(card_ranks, 0, 2);
        score = { 3,2 };
    }
    // edge case: convert three pair to two pair
    //const auto x = &score[3];
    else if (sub_score4 == std::vector<int>{2, 2, 2, 1}) {
        score = { 2,2,1 };
        int kicker = std::max(card_ranks[2], card_ranks[3]);
        card_ranks = { card_ranks[0], card_ranks[1], kicker };
    }
    else if (score[0] == 4) {  // four of a kind
        score = { 4, };
        // avoid for example 11, 8, 9
        sorted_card_ranks = card_ranks;
        std::sort(sorted_card_ranks.begin(), sorted_card_ranks.end(), std::greater <>());
        card_ranks = { sorted_card_ranks[0], sorted_card_ranks[1] };
    }
    else if (score.size() >= 5) {  // high card, flush, straight and straight flush
        // straight
        // adjust for 5 high straight
        if (std::find(card_ranks.begin(), card_ranks.end(), 12) != card_ranks.end())
            card_ranks.push_back(-1);
        sorted_card_ranks = card_ranks;
        std::sort(sorted_card_ranks.begin(), sorted_card_ranks.end(), std::greater <>());  // sort again

        for (int i = 0; i < sorted_card_ranks.size() - 4; ++i) {
            straight = sorted_card_ranks[i] - sorted_card_ranks[i + 4] == 4;
            if (straight == true) {
                card_ranks = {
                    sorted_card_ranks[i], sorted_card_ranks[i + 1], sorted_card_ranks[i + 2], sorted_card_ranks[i + 3],
                    sorted_card_ranks[i + 4] };
                break;
            }
        }

        //flush
        for (std::string card : all_cards_with_table_combined) {
            available_suits.emplace_back(card.substr(1, 1));
        }

        std::vector<int> suit_counts;
        std::vector<std::string> suit_cards;
        for (const auto& suit : original_suits) {  // why can original_suits not be a string and suit a char?
            int count = std::count(available_suits.begin(), available_suits.end(), suit);
            if (count > 0) {
                rsuits.emplace_back(std::make_pair(count, suit));
            }
        }
        std::sort(rsuits.begin(), rsuits.end(), std::greater<std::tuple<int, std::string>>());
        flush = std::get<0>(rsuits[0]) >= 5; // the most occurred suit appear at least 5 times

        if (flush == true)
        {
            auto flush_suit = std::get<1>(rsuits[0]);
            CardsWithTableCombined flush_hand;
            for (auto card : all_cards_with_table_combined) {
                if (card[1] == flush_suit[0]) {
                    flush_hand.insert(card);
                }
            }

            Score rcounts_flush = get_rcounts(flush_hand, available_ranks, original_ranks);
            // sort tuple and split into score and card ranks
            std::sort(rcounts_flush.begin(), rcounts_flush.end(), std::greater<std::tuple<int, int>>());
            card_ranks.clear();
            score.clear();
            for (auto it = std::make_move_iterator(rcounts_flush.begin()),
                end = std::make_move_iterator(rcounts_flush.end()); it != end; ++it)
            {
                score.push_back(std::get<0>(*it));  // ranks of individual cards
                card_ranks.push_back(std::get<1>(*it));  // amount of occurrences
            }

            //  # check for straight in flush
            // if 12 in card_ranks and -1 not in card_ranks : # adjust if 5 high straight
            if (std::find(card_ranks.begin(), card_ranks.end(), 12) != card_ranks.end() &&
                !(std::find(card_ranks.begin(), card_ranks.end(), -1) != card_ranks.end())) {
                card_ranks.push_back(-1);
            }

            for (int i = 0; i < card_ranks.size() - 4; i++) {
                straight = card_ranks[i] - card_ranks[i + 4] == 4;
                if (straight == true)
                {
                    break;
                }
            }
        }

        // no pair, straight, flush, or straight flush
        if (flush == false && straight == false)
            score = { 1 };
        else if (flush == false && straight == true)
            score = { 3, 1, 2 };
        else if (flush == true && straight == false)
            score = { 3, 1, 3 };
        else if (flush == true && straight == true)
            score = { 5 };
    }
    if (score[0] == 1 && potential_threeofakind == true)
        score = { 3,1 };
    else if (score[0] == 1 && potential_twopair == true)
        score = { 2, 2, 1 };
    else if (score[0] == 1 && potential_pair == true)
        score = { 2, 1, 1 };

    if (score[0] == 5)
        // # crdRanks=crdRanks[:5] # five card rule makes no difference {:5] would be incorrect
        hand_type = "StraightFlush";
    else if (score[0] == 4)
        hand_type = "FoufOfAKind"; // crdRanks = crdRanks[:2] # already implemented above
    else if (slice(score, 0, 2) == std::vector<int> {3, 2})
        hand_type = "FullHouse"; // # crdRanks = crdRanks[:2] # already implmeneted above
    else if (slice(score, 0, 3) == std::vector<int> {3, 1, 3}) {
        hand_type = "Flush";
        card_ranks = slice(card_ranks, 0, 5);
    }

    else if (slice(score, 0, 3) == std::vector<int> {3, 1, 2}) {
        hand_type = "Straight";
        card_ranks = slice(card_ranks, 0, 5);
    }

    else if (slice(score, 0, 2) == std::vector<int> {3, 1}) {
        hand_type = "ThreeOfAKind";
        card_ranks = slice(card_ranks, 0, 3);
    }
    else if (slice(score, 0, 2) == std::vector<int> {3, 1}) {
        hand_type = "ThreeOfAKind";
        card_ranks = slice(card_ranks, 0, 3);
    }
    else if (slice(score, 0, 2) == std::vector<int> {2, 2}) {
        hand_type = "TwoPair";
        card_ranks = slice(card_ranks, 0, 3);
    }
    else if (score[0] == 2) {
        hand_type = "Pair";
        card_ranks = slice(card_ranks, 0, 4);
    }
    else if (score[0] == 1) {
        hand_type = "HighCard";
        card_ranks = slice(card_ranks, 0, 5);
    }
    else
        throw std::runtime_error("Card Type error!");

    auto res = std::make_tuple(score, card_ranks, hand_type);
    return res;
}


double montecarlo(const std::set<std::string>& my_cards, const std::set<std::string>& cards_on_table, const std::vector<std::vector<std::set<std::string>>> ranges, const int number_of_players, const int iterations) { 

    int wins = 0;

    for (int i = 0; i < iterations; i++)
    {
        Deck deck;

        std::vector<int> idx_list;
        for (int i=0; i < ranges.size(); i++){
            idx_list.push_back(rand() % ranges[i].size());

        }      

        std::set<std::string> opponents_hole;
        for (int i=0; i < ranges.size(); i++){
            /*
            auto it = next(ranges[i].begin(), idx_list[i]);   this was a mistake as this just gives us the card of the set and not the entire set
            auto card_string = *it;
                opponents_hole.push_back(card_string);
            */

            auto choosen_opponent_pair = ranges[i][idx_list[i]];
            opponents_hole.insert(choosen_opponent_pair);
        }
        
                deck.remove_visible_cards(my_cards, cards_on_table);
                deck.distribute_cards(number_of_players, opponents_hole);
            std::vector<CardsWithTableCombined> cards_with_table_combined = deck.get_cards_combined();
        bool first_player_has_best_hand = eval_best_hand(cards_with_table_combined);
        if (first_player_has_best_hand == true)
            wins += 1;
    }
    double equity = (wins / (double)iterations) * 100.0;
    std::cout << "Equity: " << equity << "%" << std::endl;
    return equity;
}



Deck::Deck() {
    std::string combined;
    //std::cout << "Constructing deck..." << std::endl;
    for (char& r : ranks) {
        for (char& s : suits) {
            combined = std::string() + r + s;
            full_deck.insert(combined);
        };
    };
    //std::cout << "Cards in deck: " << full_deck.size() << std::endl;
}

void Deck::remove_visible_cards(const Hand& my_cards_, const std::set<std::string>& cards_on_table_) {
    // remove my_cards and cards_on_table from full_deck
    set_difference(full_deck.begin(), full_deck.end(), my_cards_.begin(), my_cards_.end(),
        std::inserter(remaining_cards_tmp, remaining_cards_tmp.end()));

    // remove visible table cards from deck
    set_difference(remaining_cards_tmp.begin(), remaining_cards_tmp.end(), cards_on_table_.begin(),
        cards_on_table_.end(),
        std::inserter(remaining_cards, remaining_cards.end()));

    //std::cout << "Remaining cards: " << remaining_cards.size() << std::endl;

    this->my_cards = my_cards_.cards;
    this->cards_on_table = cards_on_table_;

    //std::cout << "Removed my cards from deck...\n";
}

void Deck::distribute_cards(int number_players, const std::set<std::string> opponents_hole) {  //number_players INLCUDING YOURSELF
    constexpr size_t cards_in_hand = 2;

    std::vector<std::string> shuffled_deck(remaining_cards.begin(), remaining_cards.end());
    std::shuffle(shuffled_deck.begin(), shuffled_deck.end(), std::mt19937_64(std::random_device()()));
    std::vector<Hand> player_hands(number_players);  // empty container

    auto hand_it = player_hands.begin();
    *hand_it = Hand(my_cards);  // set my own cards
    hand_it++;

    auto card_it = shuffled_deck.begin();
    int i = 0;
    while (hand_it != player_hands.end() && i<opponents_hole.size()) {
        //*hand_it = Hand(std::set<std::string>{*++card_it, * ++card_it});
        auto it = next(opponents_hole.begin(), i);
        *hand_it = Hand(*it);
        ++hand_it;
        i++;
    }

    while (cards_on_table.size() < 5) {
        cards_on_table.emplace(*++card_it);
    }

    // print out the hands
    //for (auto const& player_hand : player_hands) {
    //  std::cout << "Cards: ";
    //  for (const auto& card : player_hand.cards)
    //      std::cout << card << " ";
    //  std::cout << std::endl;
    //}
    this->player_hands = player_hands;

    //std::cout << "Cards on table: ";
    //print_set(cards_on_table);
}

std::vector<CardsWithTableCombined> Deck::get_cards_combined() {
    CardsWithTableCombined cards_with_table_combined;
    std::vector<CardsWithTableCombined> all_cards_with_table_combined;

    for (const auto& player_hand : player_hands) {
        cards_with_table_combined = player_hand.cards;
        cards_with_table_combined.insert(cards_on_table.begin(), cards_on_table.end());
        all_cards_with_table_combined.push_back(cards_with_table_combined);
    }

    return all_cards_with_table_combined;
}

void Deck::print_set(const std::set<std::string>& set) {
    for (const auto& card : set)
        std::cout << card << " ";
    std::cout << std::endl;
}

I am done with the code but the problem is caused by the pre-existing code written by the author. I haven't changed the function which cause the problem but other stuff, which seems to work just fine. I am also trying to use cppimport to use the speed of C++ for the calculations of the Montecalro-Search and then import/use that function into my main Python code. The error I get is that the function slice can mean different things (I am from germany so the error is in german, thus I have to translate it).

Here is the error:

import cppimport.import_hook
>>> import Scoring
cl : Befehlszeile warning D9002 : Unbekannte Option "-std=c++11" wird ignoriert.
cl : Befehlszeile warning D9002 : Unbekannte Option "-fvisibility=hidden" wird ignoriert.
.rendered.Scoring.cpp
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(35): warning C4267: "=": Konvertierung von "size_t" nach "int", Datenverlust möglich
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(37): warning C4267: "=": Konvertierung von "size_t" nach "int", Datenverlust möglich
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(75): warning C4244: "Initialisierung": Konvertierung von "__int64" in "int", möglicher Datenverlust
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(113): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(114): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(115): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(119): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(162): warning C4244: "Initialisierung": Konvertierung von "__int64" in "int", möglicher Datenverlust
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(230): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(232): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(234): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(237): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(239): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(242): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(244): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(246): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(248): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(250): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(252): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(256): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(260): error C2872: "slice": Mehrdeutiges Symbol
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\Scoring.h(32): note: kann "std::vector<int,std::allocator<int>> slice(const std::vector<int,std::allocator<int>> &,int,int)" sein
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\valarray(1364): note: oder "std::slice"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(293): error C2665: "std::_Tree<std::_Tset_traits<_Kty,_Pr,_Alloc,false>>::insert": Keine überladene Funktion konnte alle Argumenttypen konvertieren
        with
        [
            _Kty=std::string,
            _Pr=std::less<std::string>,
            _Alloc=std::allocator<std::string>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xtree(1278): note: kann "void std::_Tree<std::_Tset_traits<_Kty,_Pr,_Alloc,false>>::insert(std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)" sein
        with
        [
            _Kty=std::string,
            _Pr=std::less<std::string>,
            _Alloc=std::allocator<std::string>
        ]
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(293): note: "void std::_Tree<std::_Tset_traits<_Kty,_Pr,_Alloc,false>>::insert(std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>)" : Konvertierung von Argument 1 von "_Ty" in "std::initializer_list<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>" nicht möglich
        with
        [
            _Kty=std::string,
            _Pr=std::less<std::string>,
            _Alloc=std::allocator<std::string>
        ]
        and
        [
            _Ty=CardsWithTableCombined
        ]
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(293): note: Kein benutzerdefinierter Konvertierungsoperator verfügbar, der diese Konvertierung durchführen kann, oder der Operator kann nicht aufgerufen werden
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xtree(1266): note: oder "void std::_Tree<std::_Tset_traits<_Kty,_Pr,_Alloc,false>>::insert(_Iter,_Iter)"
        with
        [
            _Kty=std::string,
            _Pr=std::less<std::string>,
            _Alloc=std::allocator<std::string>
        ]
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(293): note: „void std::_Tree<std::_Tset_traits<_Kty,_Pr,_Alloc,false>>::insert(_Iter,_Iter)“ erwartet, dass 2 Argumente – 1 angegeben werden.
        with
        [
            _Kty=std::string,
            _Pr=std::less<std::string>,
            _Alloc=std::allocator<std::string>
        ]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\xtree(1235): note: oder "std::_Tree_const_iterator<std::_Tree_val<std::_Tree_simple_types<std::basic_string<char,std::char_traits<char>,std::allocator<char>>>>> std::_Tree<std::_Tset_traits<_Kty,_Pr,_Alloc,false>>::insert(std::basic_string<char,std::char_traits<char>,std::allocator<char>> &&)"
        with
        [
            _Kty=std::string,
            _Pr=std::less<std::string>,
            _Alloc=std::allocator<std::string>
        ]

There is more to this error message, which I had to remove becaues the maximum limit is 30.000 Characters.

I tried specifying the data-type in the Scoring.cpp function but it didn't work, as I just learned C++ because I wanted to modify the Repo. I know Java (so I know that the brackets are important) but have no prior C++ experience. I don't know what the errors really mean and I have searched for explanations on how to use template functions and it seems like the code should work but it doesn't. Maybe I miss something, so any further help would be highly highly appreciated. Thanks in Advance!

  • Compiler complains that `slice` is an ambiguous name and [`std::slice`](https://en.cppreference.com/w/cpp/numeric/valarray/slice) exists. Try to remove `using namespace std;` (it's [a bad idea](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) anyway) and check if it solved this problem. – Yksisarvinen Aug 06 '23 at 20:42
  • I would start by fixing _"Unbekannte Option "`-std=c++11`" wird ignoriert."_ Who knows what C++ Standard the compiler is defaulting to. – Richard Critten Aug 06 '23 at 20:48
  • @RichardCritten i think vs 2022 defaults to c++14 or 17 so shouldn't be causing a problem – Alan Birtles Aug 06 '23 at 20:56

0 Answers0