Contest tools and workflow
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
IDE settings
Now that we successfully downloaded a replay, let's finally extract the errorstream of an entire game. This allows to reproduce every step, as long as our own bot is deterministic. My arena bot prints every input given by the referee directly to stderr so that I can read it again later.
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import json, os
# read the replay from file
with open('replay.json', 'r') as f:
replay = json.loads(f.read())
stderr = []
for frame in replay['success']['frames']:
if not 'stderr' in frame.keys(): continue
for err in frame['stderr'].split('\n'):
# some of my stderr lines aren't referee input. I marked them with '#' to filter them
if not err.startswith('#'): stderr.append(err)
#write the errorstream to the file 'input.txt'
with open('input.txt', 'w+') as f:
f.write('\n'.join(stderr))
print('\n'.join(stderr))
Enter to Rename, Shift+Enter to Preview
Now we saved all the referee input to a single file. Now we can copy it in our terminal as input. Or we configure the IDE to read from file.
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content