I want to use this Github Repo: https://github.com/zekyll/OMPEval to get the equity of ranges. I also want to use this cpp code in my main python code, so I am trying to import my cpp code, which uses this github repo, into my main python code. Because I am still just trying out if the code works, I use python in cmd (on my windows 10 machine), so my code looks like this in the command line:
import cppimport.import_hook
import Scoring
Where Scoring is the main cpp file.
Scoring.cpp
//cppimport
/*
<%
setup_pybind11(cfg)
%>
*/
#include <omp/EquityCalculator.h>
#include "Scoring.h"
#include <array>
#include <vector>
#include <iostream>
#include <tuple>
#include <algorithm>
#include <iostream>
#include <algorithm>
#include <random>
#include <iterator>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <pybind11/complex.h>
#include <pybind11/functional.h>
#include <pybind11/chrono.h>
namespace py = pybind11;
using namespace pybind11::literals;
// here is a bunch of crap from my previous attempts trying to get a different repo working but it is unnecessary as I am not using it anymore
double montecarlo_omp(){
omp::EquityCalculator eq;
std::vector<omp::CardRange> ranges{"QQ+,AKs,AcQc", "A2s+", "random"};
uint64_t board = omp::CardRange::getCardMask("2c4c5h");
uint64_t dead = omp::CardRange::getCardMask("Jc");
double stdErrMargin = 2e-5; // stop when standard error below 0.002%
auto callback = [&eq](const omp::EquityCalculator::Results& results) {
std::cout << results.equity[0] << " " << 100 * results.progress
<< " " << 1e-6 * results.intervalSpeed << std::endl;
if (results.time > 5) // Stop after 5s
eq.stop();
};
double updateInterval = 0.25; // Callback called every 0.25s.
unsigned threads = 0; // max hardware parallelism (default)
eq.start(ranges, board, dead, false, stdErrMargin, callback, updateInterval, threads);
eq.wait();
auto r = eq.getResults();
std::cout << std::endl << r.equity[0] << " " << r.equity[1] << " " << r.equity[2] << std::endl;
std::cout << r.wins[0] << " " << r.wins[1] << " " << r.wins[2] << std::endl;
std::cout << r.hands << " " << r.time << " " << 1e-6 * r.speed << " " << r.stdev << std::endl;
}
PYBIND11_MODULE(Scoring, m) {
m.def("montecarlo", &montecarlo_omp);
}
Now this code is just straight up from the README of the repo and I haven't changed anything. But when I run my cmd python code it throws this error:
.rendered.Scoring.cpp
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(79): error C2039: "function" ist kein Member von "std".
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\iostream(19): note: Siehe Deklaration von "std"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(79): error C2061: Syntaxfehler: Bezeichner "function"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(205): error C2039: "function" ist kein Member von "std".
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\iostream(19): note: Siehe Deklaration von "std"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(205): error C2143: Syntaxfehler: Es fehlt ";" vor "<"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(205): error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: "default-int" wird von C++ nicht unterstützt.
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(205): error C2238: Unerwartete(s) Token vor ";"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(71): 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(158): 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(286): warning C4267: "Argument": Konvertierung von "size_t" nach "_Ty", Datenverlust möglich
with
[
_Ty=int
]
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(456): error C2660: "omp::EquityCalculator::start": Funktion akzeptiert keine 8 Argumente
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\omp/EquityCalculator.h(77): note: Siehe Deklaration von "omp::EquityCalculator::start"
C:\Dokumente\Programmierung\AI\RL\Poker AI\gym_env\PokerEquityCalculator\EquityCalculatorMontecarlo\.rendered.Scoring.cpp(456): note: bei Anpassung der Argumentliste "(std::vector<omp::CardRange,std::allocator<omp::CardRange>>, uint64_t, uint64_t, bool, double, montecarlo_omp::<lambda_8f75a3f669e61d2a43f417576367e451>, double, unsigned int)"
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
(I am german so sorry for the german error)
In VS Code, which is the program I am writing the code in, it shows no problems and no red squiggles. I think it has something to do with the setup of cppimport.
I am using the latest cppimport, which I have intalled through pip. In my error message though, it also says right at the beginnig:
cl : Befehlszeile warning D9002 : Unbekannte Option "-std=c++11" wird ignoriert.
cl : Befehlszeile warning D9002 : Unbekannte Option "-fvisibility=hidden" wird ignoriert.
I would appreciate any further help! Thanks in Advance!
Aucun commentaire:
Enregistrer un commentaire