Perhaps the historical aspect could be structured as an array of objects. For instance...
var historicalData = [
{ ME: ['Maine', 1328361] }
];
Alternatively, if you want to reference each historical 'step' using a key, you could organize it as an object with arrays containing objects...
var historicalData = {
1: [
{ ME: ['Maine', 12334] }
]
}
In the latter scenario, the starting code might look something like this...
turn = 1
function start() {
if (typeof historicalData[turn] === 'undefined') {
historicalData[turn] = [];
}
historicalData[turn].push(stateDat);
stateDat['ME'][1]= stateDat['ME'][1] - 500; //adjust population
turn++;
}
With that being said, utilizing an object to store all the state data seems like a wise choice. Take for instance...
// Create our manager
var stateDataManager = function() { };
(function(instance) {
instance.init = function() {
// Establish internal state
this.history = {};
this.turn = 0;
this.initialized = true;
};
instance.start = function(turn, data) {
if (!this.initialized) { this.init(); }
this.turn = turn;
this.addToHistory(data);
};
instance.addToHistory(data) {
if (typeof this.history[this.turn] === 'undefined') {
this.history[this.turn] = [];
}
this.history[this.turn].push(data);
};
instance.advanceTurn() {
this.turn += 1;
};
}(stateDataManager.prototype));
// Utilize it
var manager = new stateDataManager();
manager.start(1, [
{ ME: ['Maine', 1328361] }
]);
// Progress to the next turn...
manager.advanceTurn();
// etc.