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!
- Is fun to own and watch. It reports what it does so user can be aware of otherwise invisible decisions and actions. Users can modify few memory variables to turn on/off whatever he want to focus on.
- Is conceptually effective. It runs on ideas like decentralization, self-reflection, demand-supply market and more to come.
- Is social. It allies with other colonies that has the same script, cooperates with them economically and make joint military campaigns.
- Is error-prone. Nothing in world should surprise AI except API patches. And if user messed up with Memory it may detect and solve it, or go crazy, give funny warnings and eventually deal with it. AI shall never throw the same error twice.
- Is CPU and RAM efficient. It does things as caching, heuristics, function prioritizing and deferred tasks across ticks. The technical stuff under-the-hood has to be good also.
- Is scalable. It has the same code and works as well as just spawned or managing 10 rooms.
- Is understandable. Has good documentation, clear code, meaningful variable names, to-the-point comments and etc. Devs and to-be-devs are here not onlyu to have fun, but also to learn something. So let's make it easy and fun, too.
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.
- Put down concepts into notes and probably test them (focus on conceptual effectiveness)
- Make-it-work not to die off on its own (focus on scalability)
- Make-it-work using infrastructure (focus on scalability)
- Make-it-work defending (focus on scalability)
- Make-it-work scouting & expanding (focus on scalability)
- Make-it-work aggression & conquering (focus on scalability)
- Make-it-work diplomacy (focus on scalability)
- Rewrite notes into documentation and inline comments (focus on understandable)
- Review & improve concepts (focus on conceptual effectiveness)
- Make-it-work anything new (focus on scalability)
- Improvements & make-it-work Adis - Automatic Debugging & Isolation System (focus on error-prone)
- Improvements & make-it-work MUI - Memory based User Interface (focus on fun)
- Improvements and finish 100% expected functionality (focus on CPU and RAM efficiency)
- Together build wonder worth 161.8mil energy in public server (focus on fun)
- Fork
- Make sure default branch is
master
. That's in Github settings just under repository name - It should work out-of-box (content of master branch). If not, report an issue
-
Fork
-
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
- To try out new code in 3 seconds, you can add alias in
~/.bash_profile
file
alias gitfix='git commit --all --amend --no-edit; git push -f'
- To try out new code in 3 seconds, you can add alias in
-
Pull request to any of
feature-*
branches, todevelop
, or to nextrelease-*
branch- Use tab for indents, LF line endings, 120char line length
- To make a new branch repeat steps 2.-4
- Please use 50/72 commit messages http://stackoverflow.com/questions/2290016/git-commit-messages-50-72-formatting
- For big picture here's branching model http://nvie.com/posts/a-successful-git-branching-model/
- Also good in general http://www.kmoser.com/articles/Good_Programming_Practices.php
- No hardcoded places, rates, targets, etc.
- Same code for small, big and emergency situations.
- Behavior is error, memory corruption and exception case safe.
- Swarm intelegence.
- Prioritized / flexible CPU load.
- Global parameters
pulse
is for cyclic recalculations to lower CPU load
t
is length of timespan (1=emergency,1000=longterm) the colony is in, for decision making 3.threat
is the global militarization level- Code max 120 width, tabbed, camelCase, prefer aligned, optional spacing.
Armagaddeon: 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:
- Launcher
- Economy
- Utilities
- ADIS
- Player
- Diplomat
- Ambassador (per player)
- Squad:Consul (per task)
- Ambassador (per player)
- Marshal
- Major (per war)
- Squad:Captain (per task)
- Major (per war)
- Executive
- Squad:Escrow
- Governor (per Room)
- Squad:Miner (per source)
- Squad:Militia (per gate)
- Squad:Extractor
- Squad:Police
- Squad:Builder
- Squad:Logistics
- Spawner
- Storage
- Diplomat
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
.
- owns: GCL, Memory
- produces: CPU
- rents: nothing
- wants: control points
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
- safe zone - it is behind walls
- dang(erous) zone - it is between walls and enemy
- hostile zone - it is in reach of enemy
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
.