The Accountant State & Simulation Code in C++

http://pastebin.com/dHsJMcSc

I wanted to share my code for the state representation and simulation of the Accountant challenge. I would also appreciate some feedback for further improvement.
I tried to optimize the code as much as possible without using any raw pointers and new (just references) in my code for memory allocation. This way you can use the default compiler generated copy, assignment and move constructors of C++ classes without caring about resource management yourself.
Feel free to use it for yourself :slight_smile:

1 Like

Thanks for sharing. But it doesn’t work on the Accountant, it just move to 5000, 5000. And removing the move line it just gives errors.

I’m a bit rusty in C++, but I like to review other’s code to learn how they solve the problem.
From what I see you make only one simulation each turn. In fact in this challenge you just really need the 1st status of the game, and you can calculate every next game step. So what I did is first get a 100% emulation on what’s going to happen on next turns (exact position for each and any enemy), and then force-brute simulate a lot of different States.
If you aren’t crunching numbers you really don’t need any optimization, you’ll have plenty of time.
With a good algorithm you should simulate up to 1 million per second.
In C# it worked horribly bad for me, it just timeout a lot, and with my bruteforce strategy Wolff just keep doing stupid things. Well, next time I’ll try some other strategy.

Yeah I just posted the state and the simulation here. I thought that was clear. My coding example is basically just reading the input and intializing the state. You can use that now to do programm a smart bot.

I wrote a genetic programming (GP) bot that does all the simulations and what not to calculate a good turn. I got quite far with that, but I that was my first try on GP ever and I didn’t want to post something here that shows how to not do it :stuck_out_tongue: