Get inputs provided during given round (Crystal Rush)

Hi!
This may be a general question for AI Battle games (but asking specifically for Crystal Rush). When I see my AI acting wonky during a match, I would like to troubleshoot my code, but I need a way to get the inputs that would have been provided during a specific round (e.g. state of the map, entities). Is there a way to do that? The only thing I could think of would be to print the inputs to console, but that breaks the game since printing is needed as outputs.
Thanks!

Write debug outputs.
The init template stub gives you instruction of debug command for your language.

1 Like

I’m using Python and saw the initial debug line in the template:

print("Debug messages...", file=sys.stderr)

It doesn’t though show the inputs provided by the game (I believe it would only show error messages?). From the Python docs (sys — System-specific parameters and functions — Python 3.10.4 documentation), I think I’m looking for stdin, but using this line:

  print("Debug messages...", file=sys.stdin)

gives me the error message: “io.UnsupportedOperation: not writable”.

Is there a guide somewhere on how to use debugging within the context of codeingame’s IDE? Thanks!

It should be

print(what_you_want_to_print_here_e.g._variable_name, file=sys.stderr, flush=True)

Perfect! Thank you!

1 Like

For some games with fog or other hidden information (like Crystal Rush) you probably want the whole game input and not just a single turn.
Here’s a guide: Coding Games and Programming Challenges to Code Better

Perfect! Thanks everyone for the tips!

Are there any tips for when the input stream gets too long and the stderr gets truncated with “…” instead of displaying everything? This happens to both the IDE console and the API method.

You can compress it (e.g. zip-compression is built-in for many languages or you make your own compression for the specific use-case) and then convert it to base64 before printing to stderr.
Revert the whole process to restore the initial input for offline-testing.

1 Like