I'm writing a simulation program. I need a way to record and then play back the entire simulation, at any given point. Kind of like how games like Age of Empires 2 does it, not as in actual video recording of the player's screen. My simulation consists of a really large grid of moving/changing objects. I've already had to dump the core of the program and I'm in the process of replacing it with a messaging system, so that any information that is WRITTEN to the simulation is done in a mesage format (eg. pObject->sendMessage_setDirection()) and information that is READ from the simulation is done regularly (eg. pObject->getDirection()).
This is turning out to be very hard to maintain. Every time I add a new object or a new kind of message for an existing object I have to add new code snippets all around. Mostly because messages have to travel from the top of the simulation through 2-3 layers down to the actual object, and every layer needs to know how to handle or route each and every message.
So I'm wondering if there's some clever way to go about this besides my approach. My program is relatively young so I can afford to make large changes at this point, specially if it'll make developing the rest of it easier. Recording pixel-by-pixel (video) isn't an option because the grids are supposed to be able to get really large (for example 64,000x64,000 tiles). I also thought about reading through the entire simulation after every tick (a "tick" is the smallest unit I need to record) and saving it to a file but again, it can be really large, so doing this every tick would make the whole thing very slow.
Thanks in advance.
Edited by OpOpOpOp, 15 December 2013 - 12:10 AM.