deep_learning_and_the_game_of_go icon indicating copy to clipboard operation
deep_learning_and_the_game_of_go copied to clipboard

chapter 8: Cannot receive GTP response from bot

Open Sarah112358 opened this issue 4 years ago • 6 comments

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

Sarah112358 avatar Aug 25 '19 06:08 Sarah112358

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

macfergus avatar Sep 26 '19 04:09 macfergus

can you teach me how to install Gnugo on windows?

wang869 avatar Mar 22 '20 01:03 wang869

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

xhw98 avatar Apr 01 '20 06:04 xhw98

@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

maxpumperla avatar Apr 03 '20 07:04 maxpumperla

@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 avatar May 02 '20 14:05 y-kkky

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

y-kkky avatar May 02 '20 14:05 y-kkky