Wednesday, 10 September 2014

The Very Complex Math of Sandcastle Builder

Some of the math behind Sandcastle Builder is surely accidental, and some of it is surely genius. An example of accidental is that I don't think I've ever had any useful number of castles produced by Ninja Builder or any boost that references ninja stealth level at all. Ninja Builder is there as a prerequisite for Factory Ninja and otherwise can be ignored.

And example of pure genius, even if also accidental, is how the math behind the Tool Factory works. I'm currently at the stage where I have Space Elevator and Friendship is Molpish but I don't yet have the Crystal Flux Capacitor. This means that I never have to worry about loading chips into the factory and that my source of chips is castle tools, and therefore ONGs.

Space Elevator multiplies the value of Scaffolds by one ten-thousandth of the number of ladders you have. But since the factory outputs all tools at the same time, that's basically the same as squaring the number of Scaffolds you have and dividing by ten thousand. But ten thousand is a small number, and the difference between what Scaffolds produce and what your other tools produce is a small number, and double is small so Knitted Beanies is doing the same thing. The important thing is that the chip production of your tools is O(n2).

But unlike the castle phase of the game, the cost of tools is linear. So if the tool factory produced as many tools as you has chips for, that would actually represent the acceleration of your production as well. That is, your production is increasing exponentially. Of course the factory does not produce as much as you have chips for, it is limited by Production Control which costs one million times the current number of runs to upgrade. So the price of increasing Production Control is also O(n2).

At the same time, though, you are also getting chips via the Blast Furnace and Automata Control. You need those chips to further upgrade Automata Control. Automata Control's price escalate exponentially with its current level. The number of chips you can produce is determined by the current level of Automata Control times the production of your Glass Furnace which is, at most, 100 times your Sand Purifier which costs glass blocks in linear proportion to its current level to upgrade. You are getting glass blocks by sawing them out of the chips in the factory queue, so those are being produced at O(n2) as well and the Sand Purifier cost is also O(n2).

Throughout this whole process you are exponentially increasing your number of tools by constantly creating glass on the order of the number of tools squared and spending glass on that same order. Your Automata Control level, with its exponential cost, is basically increasing linearly as your tools increase exponentially so over time you are slowly but surely approaching 300 when you can move onto the next phase of the game.

I find this part of the game immensely rewarding. It's a very long grind on the order of days to weeks, but there is steady progress in the order of magnitude of the number of tools you have and in the linear value of Automata Control. There are so many small constants being multiplied through the system that what is really going on is far from obvious without analysis.

At some point I really regretted giving up my previous game, but I'm actually really happy I'm playing through Sandcastle Builder again. Maybe I'll start looking at ways the initial gameplay experience could be improved and submitting my ideas to the GitHub. I think most of the development goes into the extreme end game that I am still months from reaching. It would be neat to see some improvements for new players - maybe in the Ninja Builder area.

No comments:

Post a Comment