maxpumperla / deep_learning_and_the_game_of_go

Code and other material for the book "Deep Learning and the Game of Go"
https://www.manning.com/books/deep-learning-and-the-game-of-go
953 stars 387 forks source link

chapter 8: Cannot receive GTP response from bot #44

Open Sarah112358 opened 4 years ago

Sarah112358 commented 4 years ago

On windows, self.gtp_stream.stdout.readline() will loop infinitely when an empty line is returned by the bot (e.g. gnugo).

macfergus commented 4 years ago

Hi @Sarah112358, thank you for reporting this. I found the solution is to set bufsize=0 on the call to Popen. See this diff for a fix: https://github.com/maxpumperla/deep_learning_and_the_game_of_go/commit/6afbe8c7ca048c946c2cb512559c9a437b6c24b6

wang869 commented 4 years ago

can you teach me how to install Gnugo on windows?

xhw98 commented 4 years ago

i also want to know how to init gnugo to play with the agnent in the book chapter 8?

maxpumperla commented 4 years ago

@wang869 @xhw98 all I can do is point you to the official documentation, which tells you how to do that: https://www.gnu.org/software/gnugo/gnugo_2.html#SEC13

y-kkky commented 4 years ago

@Sarah112358 @maxpumperla

for python3.7 smth changed in streams API. To make it work you need to do:

  1. To not be stuck forever on stdout.readline(), you need to subprocess.Popen add argument bufsize=0 like this: self.gtp_stream = subprocess.Popen( cmd, stdin=pipe, stdout=pipe, bufsize=0 )
  2. After that, another issue raises: stdout.readline() now returns bytes literal instead of the string, so check line[0] == '=' will never be true. just add .decode() for bytes string like this: line = self.gtp_stream.stdout.readline().decode()
y-kkky commented 4 years ago

nice, didn't notice that @macfergus already added diff 👍 BTW I'm on the latest master, it is strange that I still have old code