- Created Friday, January 29th 2016 @ 21:05:18
I've been testing my program with:
(cmd: ytictactoe.py < testinput.txt)
and I'm getting the output I want. On the website, it compiles fine and passes the output test:
Running testcase /opt/aigames/etc/teststictactoe/testtictactoe.txt... Testing Bot with setup input... ... finished testcase in 0.070000000298 seconds place_move 7 0
Yet when tested with "full testgame" it says there is no response. What are you doing differently between the full testgame and the output test? Any clues as to where I might be going wrong?
- Created Friday, January 29th 2016 @ 21:07:59
action move 10000
Response timed out (10000ms), let your bot return 'no_moves' instead of nothing or make it faster.
Output from your bot: null
Engine warning: "Failed to parse input ''"
- Created Friday, January 29th 2016 @ 21:08:26
Did you disable output buffering?
- Created Friday, January 29th 2016 @ 21:13:40
def outprint(text): sys.stdout.write(str(text) + '\n') sys.stdout.flush()
I use sys.stdout.flush() after each stdout, as far as I know that takes care of the buffering.
- Created Friday, January 29th 2016 @ 21:35:46
This part in particular strikes me as odd: Engine warning: "Failed to parse input ''" As that is not coming from my program, it's coming from the game engine.
- Created Friday, January 29th 2016 @ 22:01:35
I seem to have solved it, but I'm not actually sure how. Some additional documentation would be great, but I guess I don't particularly need it anymore.
- Created Friday, January 29th 2016 @ 22:31:31
I got a version pass all tests. Here's github link https://github.com/toma78/tictactoe
- Created Saturday, January 30th 2016 @ 05:05:36
I was having similar issues. I found a post in another thread about having to put a comment saying what version of python you want and main in the top of your main Python file. I had multiple files in my zip and I think it was executing the wrong one. May be this is what happened? My output was almost identical to yours.
- Created Saturday, January 30th 2016 @ 09:28:22
@toma: May be you contact the organisation to contribute that version as a Python starter bot?
- Created Saturday, January 30th 2016 @ 10:11:22
I'll send them link if they want to add it. :)
- Created Sunday, January 31st 2016 @ 14:43:44
well, I had a issue like yours, but using C... my problem was simple that the order of the update commands were changing and my bot was written to read them always in the same sequence! I just made it so the order does not matter and no more problems!
- Created Sunday, January 31st 2016 @ 18:17:43
I figured out that my problem was with input. It would first wait until there was no more input, and then start responding to it. This worked for my own data, which was just a text file it could go through, but not for live data that is fed line by line. It's working great, now :)
- Updated Monday, February 1st 2016 @ 01:32:58
Just to help other's along, here is a simplified version of what I have working right now:
import sys def outprint(text): sys.stdout.write(str(text) + '\n') sys.stdout.flush() def main(): global mynum,nums,macro while not sys.stdin.closed: cmd = sys.stdin.readline() if len(cmd) == 0: continue if (cmd[:19] == "settings your_botid"): mynum = int(cmd[20:]) elif (cmd[:22] == "update game macroboard"): macro = cmd[23:].split(",") elif (cmd[:17] == "update game field"): nums = cmd[18:].split(",") elif (cmd[:11] == "action move"): ticbot = bot(nums,macro,mynum) outprint(ticbot.makeMove()) if __name__ == "__main__": main()
edit: although toma's is much better. I just felt like sharing an alternative.