bupticybee / TexasSolver

🚀 A very efficient Texas Holdem GTO solver :spades::hearts::clubs::diamonds:
https://bupticybee.github.io/texassolver_page
GNU Affero General Public License v3.0
1.8k stars 313 forks source link

The bindSolver in Python file #142

Open vinoshuai-NLP opened 2 years ago

vinoshuai-NLP commented 2 years ago

Hi, Thanks for your woke. I am trying to run your python file to test it.

import bindSolver

But I did not find any folder or package named Bindslover. We are looking forward to your reply.

bupticybee commented 2 years ago

This part of code is kind of old and wouldn't run, if you want to use it through python, you might want to refer to colab files, not py files in the project.

vinoshuai-NLP commented 2 years ago

Could you tell me where it is? Since I would like to build the tree by myself, then run the solver. Thanks

bupticybee commented 2 years ago

Here https://colab.research.google.com/github/bupticybee/TexasSolver/blob/console/TexasSolverTechDemo.ipynb

bupticybee commented 2 years ago

Could you tell me where it is? Since I would like to build the tree by myself, then run the solver. Thanks

It's possible. Follow the ipynb file above.

Building tree by python is also possible, I would refer to https://github.com/bupticybee/TexasHoldemSolverJava/blob/master/src/test/resources/python/java_interface.py#L97

Please take a look.

Sam44y commented 1 year ago

Hi @bupticybee, thanks for all the work you have put into this project. It's awsome!

I've tried to follow the colab files to run a python script on windows and am stuck unfortunately. Setting the global, flop, turn and river settings all seem straight forward python. When I get to start solving, I run into problems and am not sure if there is a way to directly call the windows TexasSolver files or try do it directly through the console?

I tried through the console by adding different methods from subprocess with no luck: from subprocess import Popen, PIPE

p = Popen([../TexasSolver-v0.2.0-Windows/console_solver.exe, '-i', '../TexasSolver-v0.2.0-Windows/resources/text/commandline_sample_input.txt'], stdout=PIPE, stdin=PIPE)

Any help or direction on to how I could use the solver and access the results in a python script on windows would be great? Thanks again.

bupticybee commented 1 year ago

Hi @bupticybee, thanks for all the work you have put into this project. It's awsome!

I've tried to follow the colab files to run a python script on windows and am stuck unfortunately. Setting the global, flop, turn and river settings all seem straight forward python. When I get to start solving, I run into problems and am not sure if there is a way to directly call the windows TexasSolver files or try do it directly through the console?

I tried through the console by adding different methods from subprocess with no luck: from subprocess import Popen, PIPE

p = Popen([../TexasSolver-v0.2.0-Windows/console_solver.exe, '-i', '../TexasSolver-v0.2.0-Windows/resources/text/commandline_sample_input.txt'], stdout=PIPE, stdin=PIPE)

Any help or direction on to how I could use the solver and access the results in a python script on windows would be great? Thanks again.

Hmm, wired problem. First I'm not sure what kind of error you get here, suggest also paste all the error.

Second, without the "-i" option, the solver would auto load compair file and wait for stdin, and now if you feed the content of the config file(in your case, commandline_sample_input.txt) directly into the stdin, the solver will start to solve, and it's the suggested way to run under script.

bupticybee commented 1 year ago

Hi @bupticybee, thanks for all the work you have put into this project. It's awsome! I've tried to follow the colab files to run a python script on windows and am stuck unfortunately. Setting the global, flop, turn and river settings all seem straight forward python. When I get to start solving, I run into problems and am not sure if there is a way to directly call the windows TexasSolver files or try do it directly through the console? I tried through the console by adding different methods from subprocess with no luck: from subprocess import Popen, PIPE p = Popen([../TexasSolver-v0.2.0-Windows/console_solver.exe, '-i', '../TexasSolver-v0.2.0-Windows/resources/text/commandline_sample_input.txt'], stdout=PIPE, stdin=PIPE) Any help or direction on to how I could use the solver and access the results in a python script on windows would be great? Thanks again.

Hmm, wired problem. First I'm not sure what kind of error you get here, suggest also paste all the error.

Second, without the "-i" option, the solver would auto load compair file and wait for stdin, and now if you feed the content of the config file(in your case, commandline_sample_input.txt) directly into the stdin, the solver will start to solve, and it's the suggested way to run under script.

You can experiment it by something like:

cat commandline_sample_input.txt | ./console_solver 

in Linux, I'm sure there are way to do it in windows

Sam44y commented 1 year ago

Thanks for getting back to me and the tips. I tried doing as you say but am still having the problem. Here's what I used: from subprocess import Popen, PIPE

command = '../TexasSolver-v0.2.0-Windows/console_solver.exe'

p = Popen(command, shell=True, stdout=PIPE, stdin=PIPE)

# input_str comes from the TexasSolver colab code p.stdin.write(input_str.encode()) p.stdin.close()

output = p.stdout.read() p.wait()

print(output.decode())

The output I get is: <<<START SOLVING>>>

Using 2 threads

Iter: 0 It then just finishes, so I'm not sure what is happening if you have any ideas? I'm using sublime editor build to run the script.

bupticybee commented 1 year ago

No way... can you give a minimal example of your project? I'd like to debug it myself in my PC.

Sam44y commented 1 year ago

Yeah sure, I added a minimal version for testing here https://github.com/Sam44y/minimal-example-for-testing-TexasSolver-python.git

Thanks heaps for your help! I appreciate it

bupticybee commented 1 year ago

Yeah sure, I added a minimal version for testing here https://github.com/Sam44y/minimal-example-for-testing-TexasSolver-python.git

Thanks heaps for your help! I appreciate it

Nice, I will test it on weekends.

Sam44y commented 1 year ago

hi @bupticybee, any luck at all with this by any chance?

bupticybee commented 1 year ago

hi @bupticybee, any luck at all with this by any chance?

Havn't got the time, will get back to this after testing

Sam44y commented 1 year ago

no worries at all, thanks