Understanding state.json - Do we have access to the last command?

Been trying to understand the constraints around state.json files and the command.txt files.

What I understand so far,

  • The bots use a condensed state.json file and the opponentMap is the map that shows the history of shots that my bot made?
  • The opponent map doesn’t seem to show the order in which shots took place?
  • Do the bots have access to their previous command.txt files or are they deleted in tournament mode?
  • I presume the bots cannot save extra data for their own use in state.json(like the last shot fired)?

I thinks points 1 and 2 are correct…‘think’ being the operative word.

I also think point 3 would be a Maybe. I understand a Bot will receive a PlayerKey and Working Directory. Perhaps try loading ‘command.txt’ in tournament mode and let us know if it works!

I think you’re right on 4 too. Try creating your own, personal file to save extra data between Rounds.

Hi ShiraazM,

You care correct on points 1. Unfortunately we do not store the sequence of the shots you made anywhere no. In tournament mode your bot will only have access to the files for the current round while your bot is executing, all files are removed between bot execution runs. You are more than welcome to store your own state file within your bot’s execution directory. This directory will live for the entire match and will be deleted after a match has completed.

So I tried writing my own file and reading it between rounds in tournament mode. It looks like this works. Given that we can do this, there’s no point worrying about previous command.txt files anymore.

@Wackymax So I finally got some time to work on my bot again and it seems like I was mistaken.

  • A player is able to my their own files in the execution directory (e.g. /Round 12/Player A/data.txt)
  • But they are not copied to the next round’s working directory (next directory is /Round 13/Player A according to game engine). So while you can write your own information, you don’t really get access to it in the next round unless you hack your way around the directory naming conventions.

So I am not sure what the recommendations would be to store custom state files. Can I simply rely on saving files in a directory outside of the game engine’s execution directory (e.g. C:\Temp\PlayerKey\myData.txt)? Is something like that within the rules of the game?

You can simply write to a file in your current directory, so simply write to “myData.txt” or similar.

Perhaps upload your bot, even if it’s not ready, and see what get’s created (and where it gets created) after the test match. @gustav is on the money though

Hi ShiraazM,

When I say execution directory I mean the directory where your bot executable is run from, not the directory passed to your bot in the arguments. In other words, the same directory where the state.json file is. Most programming languages will be able to give you current working dir where your programming is being executed from.

@gustav @mvariyawa going to try your suggestions. Thanks for the help guys.

@Wackymax Ahh ok, thanks for that clarification. It makes sense now :slight_smile: .