I have already invested in my scripting language of choice, obfuscating key codes paths. For details, see my earlier post:
That got me feeling like less of an amateur putting my code in the wild. The next step was running node.js server-side, to verify client submitted games. Setting up node.js was straightforward, scripts can be easily added to the node.js daemon “pm2”. They can be run on the command line to capture STDERR directly.
Next I wrote some node.js to replace an earlier PHP script, which took client-submitted games and inserted them in the database. “newscore.php” became “newscore.js”. I did this without any idea how long full support of the engine would take (two months), but doing so got me familiar with node.js, and got some important libraries installed. To streamline operations I disabled cross site scripting detection.
I started encoding all game inputs (that successfully impact game state), and passing them on new score submission, along with a pro mode flag (pro mode starts at level 2). I had the server code try to emulate the client-submitted game and validate checksums.
I then noticed huge discrepancies between client and server output, along the lines of pseudorandom number generation. To make the game fully deterministic, I:
- Made a prng server, taking seeds and giving out number sets.
- Standardized consumption and use of in-engine prng.
- Cleaned out external prng consumption by the graphics engine.
I also had to eliminate other sources of low-level indeterminism:
- Open-ended data sorting
- Iterations like for .. in
- High precision operations
My biggest impediment was not being used to debugging on node.js. I basically did all by hand in the console, working with seeds and execution paths that were problematic. I procrastinated on setting up my pipeline, so was manually juggling files for a few nights.
One problem I now experience is that the deploy pipeline is so memory-intensive that the mysql daemon shuts down, poor Battle Mines. I think I’ll have to refurbish the devbox at some point, maybe separate out concerns. 😉
In other news, check out OGBM! The old-schooliest of the Battle Mines games, now hosted by an old afficionado! http://ogbm.pw