ericgjackson / slumbot2019

Implementations of CFR for solving a variety of Holdem-like poker games
MIT License
133 stars 31 forks source link

make error #1

Closed kli-casia closed 5 years ago

kli-casia commented 5 years ago

Hi, @ericgjackson I want to learn the CFR algorithm with your wonderful code

But when I run make bin/build_hand_value_tree The following error occurs

src/vcfr_state.cpp: In function ‘std::shared_ptr<double []> AllocateOppProbs()’:
src/vcfr_state.cpp:38:46: error: no match for ‘operator[]’ (operand types are ‘std::shared_ptr<double []>’ and ‘int’)
   for (int i = 0; i < num_enc; ++i) opp_probs[i] = 1.0;
                                              ^
src/vcfr_state.cpp: In constructor ‘VCFRState::VCFRState(int, const HandTree*)’:
src/vcfr_state.cpp:55:94: error: cannot convert ‘double (*)[]’ to ‘double*’ for argument ‘3’ to ‘void CommonBetResponseCalcs(int, const CanonicalCards*, double*, double*, double*)’
   CommonBetResponseCalcs(0, hands, opp_probs_.get(), &sum_opp_probs_, total_card_probs_.get());
                                                                                              ^
src/vcfr_state.cpp: In member function ‘int* VCFRState::StreetBuckets(int) const’:
src/vcfr_state.cpp:103:39: error: invalid use of array with unspecified bounds
   return street_buckets_.get() + st * max_num_hole_card_pairs;
                                       ^
src/vcfr_state.cpp:103:39: error: cannot convert ‘int (*)[]’ to ‘int*’ in return
In file included from /usr/include/c++/5/bits/shared_ptr.h:52:0,
                 from /usr/include/c++/5/memory:82,
                 from src/vcfr_state.cpp:11:
/usr/include/c++/5/bits/shared_ptr_base.h: In instantiation of ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*) [with _Tp1 = int; _Tp = int []; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’:
/usr/include/c++/5/bits/shared_ptr.h:117:32:   required from ‘std::shared_ptr<_Tp>::shared_ptr(_Tp1*) [with _Tp1 = int; _Tp = int []]’
src/vcfr_state.cpp:27:49:   required from here
/usr/include/c++/5/bits/shared_ptr_base.h:882:39: error: cannot convert ‘int*’ to ‘int (*)[]’ in initialization
         : _M_ptr(__p), _M_refcount(__p)
                                       ^
/usr/include/c++/5/bits/shared_ptr_base.h: In instantiation of ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(_Tp1*) [with _Tp1 = double; _Tp = double []; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’:
/usr/include/c++/5/bits/shared_ptr.h:117:32:   required from ‘std::shared_ptr<_Tp>::shared_ptr(_Tp1*) [with _Tp1 = double; _Tp = double []]’
src/vcfr_state.cpp:37:54:   required from here
/usr/include/c++/5/bits/shared_ptr_base.h:882:39: error: cannot convert ‘double*’ to ‘double (*)[]’ in initialization
Makefile:29: recipe for target 'obj/vcfr_state.o' failed
make: *** [obj/vcfr_state.o] Error 1
ericgjackson commented 5 years ago

Hi,

Looks like an issue with features of C++ that were only added in C++ 17. I've changed the Makefile so that "-std=c++17" is added as an option to gcc. That may help. But you'll also need to make sure you are using a version of gcc that supports C++ 17.

Looks like I am using:

gcc --version gcc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0

By the way, be aware that the code in this repository is under development, although the basic features should always work.

On Tue, Jun 11, 2019 at 1:01 AM Kai Li notifications@github.com wrote:

Hi, @ericgjackson https://github.com/ericgjackson When I run make bin/build_hand_value_tree The following error occurs

src/vcfr_state.cpp: In function ‘std::shared_ptr<double []> AllocateOppProbs()’:

src/vcfr_state.cpp:38:46: error: no match for ‘operator[]’ (operand types are ‘std::shared_ptr<double []>’ and ‘int’)

for (int i = 0; i < num_enc; ++i) opp_probs[i] = 1.0;

                                          ^

src/vcfr_state.cpp: In constructor ‘VCFRState::VCFRState(int, const HandTree*)’:

src/vcfr_state.cpp:55:94: error: cannot convert ‘double ()[]’ to ‘double’ for argument ‘3’ to ‘void CommonBetResponseCalcs(int, const CanonicalCards, double, double, double)’

CommonBetResponseCalcs(0, hands, oppprobs.get(), &sum_oppprobs, total_cardprobs.get());

                                                                                          ^

src/vcfr_state.cpp: In member function ‘int* VCFRState::StreetBuckets(int) const’:

src/vcfr_state.cpp:103:39: error: invalid use of array with unspecified bounds

return streetbuckets.get() + st * max_num_hole_card_pairs;

                                   ^

src/vcfr_state.cpp:103:39: error: cannot convert ‘int ()[]’ to ‘int’ in return

In file included from /usr/include/c++/5/bits/shared_ptr.h:52:0,

             from /usr/include/c++/5/memory:82,

             from src/vcfr_state.cpp:11:

/usr/include/c++/5/bits/shared_ptr_base.h: In instantiation of ‘std::__shared_ptr<_Tp, _Lp>::shared_ptr(_Tp1*) [with _Tp1 = int; _Tp = int []; gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’:

/usr/include/c++/5/bits/shared_ptr.h:117:32: required from ‘std::shared_ptr<_Tp>::shared_ptr(_Tp1*) [with _Tp1 = int; _Tp = int []]’

src/vcfr_state.cpp:27:49: required from here

/usr/include/c++/5/bits/shared_ptr_base.h:882:39: error: cannot convert ‘int’ to ‘int ()[]’ in initialization

     : _M_ptr(__p), _M_refcount(__p)

                                   ^

/usr/include/c++/5/bits/shared_ptr_base.h: In instantiation of ‘std::__shared_ptr<_Tp, _Lp>::shared_ptr(_Tp1*) [with _Tp1 = double; _Tp = double []; gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’:

/usr/include/c++/5/bits/shared_ptr.h:117:32: required from ‘std::shared_ptr<_Tp>::shared_ptr(_Tp1*) [with _Tp1 = double; _Tp = double []]’

src/vcfr_state.cpp:37:54: required from here

/usr/include/c++/5/bits/shared_ptr_base.h:882:39: error: cannot convert ‘double’ to ‘double ()[]’ in initialization

Makefile:29: recipe for target 'obj/vcfr_state.o' failed

make: *** [obj/vcfr_state.o] Error 1

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ericgjackson/slumbot2019/issues/1?email_source=notifications&email_token=ABUMRNMQO3TH7S74PY7MTRTPZ5LUFA5CNFSM4HW3SL4KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GYXWHOA, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUMRNLAT4ZWNUDJVYP6RV3PZ5LUFANCNFSM4HW3SL4A .

kli-casia commented 5 years ago

Thanks, I have change my gcc from 5.4 to 7.4, it works fine now.