# CodeCraft.js demo

There is now a working Javascript/WebGL version of CodeCraft, go check it out: http://cswinter.github.io/codecraftjs-demo/

Getting this to work was surprisingly easy, mad props to everyone behind Scala.js for creating such an awesome piece of technology.

I will now be adding a Javascript API and an in-browser editor and command line and use that to create an interactive tutorial. So there is still some work to be done, but I expect to have most of this up and running by early August.

## 5 thoughts on “CodeCraft.js demo”

1. Om

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. 🙂

1. codinggame

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.

2. Om

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.

1. codinggame

I’ve added a method Game.spec(modules) which creates a DroneSpec object that contains the raw module counts and additional properties such as resourceCost. All drones now also have a property totalAvailableResources which 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.

This site uses Akismet to reduce spam. Learn how your comment data is processed.