Hi Hennie,
Any suggestions on whats the best way to debug a bot in visual studio.
My current solution is to add a Debugger.Launch(); inside the bot code, and set my bot’s to execute the battleship app with all the relevant arguments.
Then VS prompts me which debugger to use
Attach to process method won’t suffice because battleship launches and ends the bot so fast each round.
You can have a look in the log.txt file that is written every round to see what the command line arguments tend to look like.
One hassle at the moment is that the state.json file is currently deleted for all the rounds except the last one, so what I do is simply to log the content of the state.json file just as my bot starts up, so I can paste it back into a file if I want to do some debugging, or run the round again after some changes to my bot.
Gustav has a good suggestion and that is what I usually do. In cases where I really want to get debug across multiple rounds or train a machine learning algorithm however I usually modify the game engine code.
Because you are using .Net you can run your bot directly from the game engine. My suggestion would be to download the source code for the game engine and then extend the player class, you can then start the game with your bot as one of the players, that way you are in the same process as the game engine and can debug fairly easily.
Alternatively modify the BotRunner class to load your main method directly by importing your project/bot into the class and then run it directly instead of starting a new process.
As gustav suggested you can save a state.json file and start your bot manually with that as the argument.
Another alternative would be to change the game engine slightly so it starts the java bot with remote debugging parameters. That way for every round the java program will start and will wait for the remote debugger to connect before continuing with execution. Just remember to run the game engine with the -nolimit parameter so that it doesn’t kill your bot for going over time.
I’m still a bit lost. I know how to add the cmd line arg for the battleships to play with my bot…but I don’t know how to be able to debug the bot itself…I’ve been using the Log function built-in but I need to access it live…There’s a flaw in my logic but I can’t see it