I'm a C++ programmer by profession, so the switch to JavaScript has been difficult, and I am unfamiliar with just the basics of how to run an AI, much less in JavaScript, so I'm having trouble getting started. I've been reading the API documentation, but that and the tutorial haven't helped in getting creep creation and assignment automated (not that I've found at least), so I'd appreciate all the help I can get. I've spent all day today and into the evening just trying to automate creep worker creation in the tutorial and haven't been successful.
Suggestions?
I still haven't figured out what should be in charge of creep creation and assignment. I'm tentatively settling on having the individual spawners be the "brains" of a room, if you will, for creating worker creeps and assigning them to specific tasks (harvest this resource, upgrade spawner, etc.), and during creation give each creep an "update" method that can be called from the main loop and that contains the stuff that a particular creeper should be interested in.
Problems:
- To optimize resource gathering, the spawners will need to be quite aware of
- All their room's resources
- The paths to said resources (I don't know how to extend an existing spawner object to keep this info around)
- Info on how fast a custom worker creep can travel and harvest (maybe a prototype sitting as a private const member)
- The travel time for a worker creep to travel to that resource, harvest, and travel back to drop it off (I've been stumped by this calculation for hours)
- Limited CPU
- Limited energy
I don't know how to work these into my logic. I haven't even figured out pseudocode yet that takes all these things into account, much less pseudocode that makes sense.
So many things to consider and now I'm tired. I'd appreciate feedback on how to begin automating creep construction and assignment.