At this moment all ideas ar work in progress. dev
and master
are both broken. I hope to get structure and concepts in place, as well creeps doing basic jobs as soon as possible (spring 2017?). That will be called version Alpha 1.0 and from that on I invite everyone to join in to develop this further together.
Check out
legacy
branch for simple code that runs a room on 3.50 CPU/tick.
Create BraveBot that in cooperation with its kind will unite the server into a brave new world. Community! Identity! Stability!
Currently I am only putting down to text and testing all ideas. Code mismatch with documentation in most parts, and there are several obsolete and broken parts. Also code contains unrelated basic logic to survive and make testing easier. I expect to move to organized developing somewhat soon, feel free to jump in to discuss concepts through issues or email.
master
. That's in Github settings just under repository nameFork
Change default branch to develop
. That's in Github settings just under repository name
It should work and not throw basic errors but use with caution
To trigger screeps.com to repull your code from default branch commit on any branch
Test & play around
~/.bash_profile
filealias gitfix='git commit --all --amend --no-edit; git push -f'
Pull request to any of feature-*
branches, to develop
, or to next release-*
branch
pulse
is for cyclic recalculations to lower CPU loadt
is length of timespan (1=emergency,1000=longterm) the colony is in, for decision makingthreat
is the global militarization levelArmagaddeon: var t = Memory.creeps; for(i in Memory){ Memory[i] = undefined; }; Memory.creeps=t;
API calls:
// Every line starts with "var t=Game.getUsedCpu(); for(i=0;i<100;i++){ ", ends with "}; console.log(Game.getUsedCpu()-t);" and is entered into console.
Game.rooms.W4N5.lookAt(25,41); // 100-120 CPU
Game.rooms.W4N5.find(FIND_STRUCTURES, {filter: { structureType: STRUCTURE_SPAWN }}); // 2.0-6.5 CPU
Game.rooms.W4N5.find(FIND_DROPPED_ENERGY); // 1.5-5.5 CPU
Game.spawns["Spawn1"]; // 0.2-0.35 CPU
Game.getObjectById("557293f459189a99084ffa68"); // 0.2-0.35 CPU
test = new RoomPosition(1,1,'W8N4'); // 0.37-0.40
Javascript itself:
var t=Game.getUsedCpu(); var test="kuku"; for(i=0;i<1000;i++){ test=test||"blah" }; console.log(Game.getUsedCpu()-t); // 2.5-3.0, all types
var t=Game.getUsedCpu(); var test="kuku"; for(i=0;i<1000;i++){ if(!test){test="blah"}; }; console.log(Game.getUsedCpu()-t); // 1.5-2.0, all types
Code consists of multiple tighly integrated modules. For module specific documentation see doc/<module>.md
. Beware that main.js
is automatically built using gulp to incoporate list of modules and bypass require
of them.
Code consists of multiple modules that communicate to each other directly via object methods (according to globally defined API) and indirectly via Memory (according to global data model). Internal logic of module can be interchanged without global problems, thus multiple alternative modules are supported and encouraged. When modules are hierarchical, the parent also tracks and measures performance of childs. If child behaves badly then parent may decide to change its logic to alternative module. Every module with "Squad" in it actually may control a creep, others don't. First and second level or hierarchy are "virtual" in a sense that they directly interact only with other modules and memory. The list of modules are as follows:
Naming convention (everyone ending with .js
): *_launcher
, *_economy
, *_utilities
, *_adis
, *_player
, *_diplomat
, *_ambassador
, *_marshal
, *_major
, *_executive
, *_governor
, *_spawner
, *_storage
, *_squadConsul
, *_squadCaptain
, *_squadMiner
, *_squadMilita
, *_squadExtractor
, *_squadPolice
, *_squadBuilder
, *_squadLogistics
.
Scans folder for modules and requires them, caches objects or rebuids from memory, and executes modules.
Provides Agent
class and bazaar*
objects. Agent
is class from which every economic player inherits that handles all transactions, accounting and metrics. bazaar*
are objects that represent various internal markets for energy, creeps, etc. Everyone that inherits from Agent
interacts with each other through one or more bazaar*
.
Miscellaneous stuff used globally, for example logger.
The Automatic Debugging & Isolation System is used globally. It contains various routines that's main goal is to prevent coma as gracefully as possible.
It is you! It also is an Agent
.
They deal with allies, manual trade, communication and other diplomatic stuff. To be developed a lot later.
They deal with war, mostly offence and perhaps also strategic defense. To be developed later.
They deal with production and defense. Developing now.
Executive has mapped nearby room for their tactical usefulness and best locations for deff squads. According to their placement territory is divided into zones, and each zone has either state
Also Executive polls governor opinions about other rooms for their income potential and best spawn placement, thus prioritizing which room to take next.
Every room has a Governor. Governors plan structure layout, caches "paths", trade, supply other governors.
There is API and Memory data Model for each pair up & down the hierarchy, e.g. Executive to Governor. Also, globally API is present from each Agent to modules economy
, utilities
and adis
.