Skip to content
This repository has been archived by the owner on Sep 29, 2018. It is now read-only.

Respecting the screeps ai api

Anthony Van de Gejuchte edited this page May 25, 2015 · 3 revisions

Following document explains the guidelines the core API should follow (and nothing else).

Memory

Following fields should be set to:

  • Memory to {}
    • Memory.spawns to {}
    • Memory.sources to {}
    • Memory.spawnQueue to AI.settings.spawnQueue
    • Memory.spawnPriorityQueue to AI.settings.spawnPriorityQueue

Each Memory.spawn member field should be set to:

  • Memory.spawns[spawn] to {}
  • Memory.spawns[spawn].spawnQueue to []
  • Memory.spawns[spawn].spawnPriorityQueue to []

All memory is guaranteed to be removed except Memory.permanent

Gathering statistics

  • Code extensions/tools/hooks/getStats.js
  • Gathers game state of the beginning of the round (and should be the only plugin to do that)

Keeping statistics in memory

  • Uses Memory.stats to add new data
  • Has a pre hook to move Memory.stats to Memory.statsHistory
    • So any other code executed after pre can store data (post hooks and stages behind pre can store data to it)

Creep memory

  • <creep>.memory.role contains the role of the creep
  • Death checker reserves <creep>.memory.copyOnDead. If set this determines if the creep will spawn or not.
Clone this wiki locally