- Created Thursday, May 12th 2016 @ 04:19:22
Hey guys, I've managed to create my first bot for the four in row challenge in Python. I'm just wondering why the engine doesn't let you use Python 3's input() and print() functions to process input and output commands? My understanding is that they also go through the standard input and output. Any help would be appreciated!
- Updated Thursday, May 12th 2016 @ 23:08:42
I had a really interesting (and long) weekend about this :-)
The only working solution I found is to use print with the flush parameter
print('place_disc 0', file=sys.stdout, flush=True)
for the output, and
print('hello log!', file=sys.stderr, flush=True)
for the logs.
See the print docs for more details. About the input function: I did not try it, I use the sys.stdin.readline() function, and it works. Oh, and remember that you have to import sys.
PancakersCreated Saturday, January 21st 2017 @ 04:05:07
You could also try using Python 2.7 syntax because i think that's the version the game servers are running. That info is found on the languages page here: http://theaigames.com/languages/python
It looks something like this for inputs:
and printing looks like this:
print "hello world"