Getting this to work was surprisingly easy, mad props to everyone behind Scala.js for creating such an awesome piece of technology.
I’ve enjoyed making an AI that can beat the final tutorial scenario and single player scenario 1, at least sometimes. However, scenario 2 will be oddly hard, I think, unless the drone.spec API works, especially for this.drone.spec.storageModules, since there are quite a few large crystals which can’t be mined without an enormous miner, so the miners at least need to be able to see which crystals they can’t mine. mineral.size does seem to work, but this.drone.spec.storageModules shows undefined. And of course, you realize what this needs is the ability to post AI’s for others to try to beat. With score tables. 🙂
Thanks for taking the time to comment, this kind of feedback is really valuable. I’ve pushed a fix and drone.spec should now work as expected.
As it happens, the next big feature I am planning to add is multiplayer. This will take at least a few more weeks though.
Also, because it seems that a mothership does nothing while constructing, it’d be invaluable to be able to read how much resources one has on hand, and be able to test against the resources needed to build a ship, and therefore choose not to do so in some (most) cases. Often a mothership is stuck building when it won’t be able to finish due to lack of supplies, and I don’t see a way to either predict (i.e. not start with insufficient supplies) that, or to break out of that status and move around once started. It’d also be mechanically solved if construction simply wouldn’t start when there’s insufficient resources.
I’ve added a method
Game.spec(modules)which creates a
DroneSpecobject that contains the raw module counts and additional properties such as
resourceCost. All drones now also have a property
totalAvailableResourceswhich will give a count of the current supplies, including any unprocessed mineral crystals that the drone will convert into resources.
If you think there’s anything else that could be smoothed out, do let me know.
That sounds like what’s needed. I’ll try it out and write back when tested.