Contest tools and workflow
eulerscheZahl
24K views
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. By 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))
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.
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.