Objects initialized outside of loop get constantly reset
-
Hello,
I've only been playing/coding in this game for a couple hours (the last ~12h to be exact, it's really addicting - probably the end of all other games for me) so I'm not sure if this is actually a problem or not:
My JavaScript VM seems to be periodically being reset ( I guess, because the console is showing my debug statement in the constructor over and over again, sometimes every few seconds, sometimes it takes a few minutes).
This obviously occurs whenever I reload the code.
I've also tested it with an empty main.js file and only a single console.log(...) line above the module exports. Same problem.I'm concerned about this because I do a lot of heavy lifting early and CPU shortly spikes every time the VM resets.
Is this normal or not?
Thanks for you help.
Here are the files:
This is my "ai.bundle.js" file (shortened, important stuff is there).
class AI {
constructor() {
// ...
console.log("# Startup - Done");
}
configure() {
// ...
console.log("# Configure - Done");
}
tick() {
// ... do actual tick loop
}
}
// ... tons of classes omitted for clarity ...
var ai = new AI();
// configure post construct
ai.configure({ /* ... configuration parameters skipped */ });
module.exports = ai;And this is the "main.js"
var ai = require('ai.bundle');
module.exports.loop = function () {
ai.tick();
};
-
Ye it's all normal, everyone has it.
-
Thank you. Guess I'll have to cache some more results in Game.memory[...].