Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

screeps-bot-choreographer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

screeps-bot-choreographer

An bot for Screeps

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Screeps Bot - Choreographer

An bot for Screeps. Implemented following the OS pattern with processes communicating via Message Queues and Event Streams. Named after [Choreography in Event-Driven Architecture)[https://www.linkedin.com/pulse/orchestration-vs-choreography-why-do-some-architects-run-paul-perez/?trk=articles_directory].

Key Features:
  • Creep logic implemented using Behavior Trees (BT)
  • Tracing (metrics, logging) and Feature Flag logic to aid development/debugging
  • Remote harvesting/mining
  • Miners w/ container and haulers
  • Buy/sell minerals
  • React and distribute compounds with a focus on "upgrade" boost
  • Explore rooms and store notes in memory
  • Haulers managed by PID controller
  • Scheduler & Processes & Threads
  • Message bus w/ topics for IPC
  • Event streams w/ consumers
  • Automatic expansion and base building
  • HUD
Roadmap:
  • Sustainably upgrade RCL in tutorial room
  • Scale creep parts based on room capacity
  • Organize logic and fix how builders and repairers source their energy
  • Implement behavior tree
  • Migrate creep roles to behavior tree
  • Storage construction triggers Distributors and prioritized Storage usage
  • Attack flag
  • Refactor movement and storage selection (more hauling with fewer Distributors)
  • Kingdom refactor
  • Refactor creep manager
  • Track time between end and start of spawns and increase/decrease min energy (Spawn Time Governor)
  • Auto-defence of owned rooms
  • Scale number of repairers based on repair needs of the room
  • Scale number of builders based on number of construction sites in room
  • Scale number of haulers based on fullness/rate of harvesting
  • Refactor and support multiple spawners in room
  • Auto-manage Upgraders per spawn (maximize what the economy can support - net zero energy)
  • Auto return-to-home and defense of remote harvesters
  • Don't require Build flags, staff rooms w/ construction sites, use flags to prioritize nearby sites
  • Refactor role and spawn logic to support easy addition of creep roles
  • Implement Scheduler, Process, and other OS components
  • Move Creeps to scheduler
  • Auto attack of weaker players
  • Intra-shared movement and claiming
  • Proper event stream
  • Auto-construction of roads to remote sources
  • Automatic layout and expansion
  • System for a Room and Map(beta) HUD
  • Remove "org" model
    • Room
      • Move hostile tracking (deleted logic)
      • Move defense
      • Move tracking of damaged creeps
      • Move structure repairing
      • Move sharing of boost details
      • Move resource tracking
    • Observer (move into Base Observer)
    • Colony
    • Kingdom
      • Use AI for accessing topics, planner, scheduler, etc...
      • Move path cache, cost matrix cache, and resource gov. to AI
    • Refactor Resource Governor into a Process
      • Move to TypeScript
  • Replace references to 'colony' with 'base'
  • Refactor thread API
    • Strongly typed thread API
    • Automatically run threads and sleep main process correct amount of time
  • No explicit Any rule
    • Scribe memory
    • Global/heap variables
    • War Manager memory
    • Central Planning memory
    • Persistent memory
  • Switch first links to be controller and source, update miner to keep link full when not mining
  • Double buffer topics when TTLing messages
  • All of project on TypeScript
  • Fix restoring of Room Entries
  • Refactor PID controller
  • Influence map library
  • Move creep definitions into individual creep files
  • TD: Room process and sources processes no longer require room visibility
  • TD: Replace spawn topics (TTL) with event streams (manages own queue)
  • Cleanup old construction sites automatically
  • Scale creep parts and remote mining based on spawner saturation
  • Harvest commodities & factory
  • Process stats and scheduler report
  • Factor room resources when selecting new base
  • Sieging of RCL>=7 rooms
  • Quads moving coherently 100% of time
  • Buff ramparts and walls to withstand nuke
  • Move all data sharing between processes to topics/IPC (remove direct access)
  • Improved defenders that hide in ramparts
  • Collect Power
  • Create & drive Power Creeps
  • Apply buffer to lvl 8 rooms
  • Allow buffer manager to nuke and time sending attackers
  • Police portal rooms
  • Attack other players getting commodities/power

Usage as bot in private server

  1. Install the bot
npm install screeps-bot-choreographer --save
  1. Add "choreographer": "node_modules/screeps-bot-choreographer/dist/main.js" to mods.json

Building and running as a player

Backup your existing scripts.

Note this project uses LF, not CRLF, and the linter will complain if it files with CRLFs. The project is setup for EditorConfig. Please use that.

Requirements:

  • Node 16+
npm install grunt-cli -g
npm install

Create .screeps.json and provide credentials:

{
  "email": "<email>",
  "token": "<token>",
  "branch": "default",
  "ptr": false,
  "private": {
    "username": "<username>",
    "password": "<password>",
    "branch": "default",
    "ptr": false
  }
}

Token is gotten from the the account settings in the Screeps client. The private username and password for private servers are set via the private server CLI tool.

Running

After making changes run linting, tests, and TS complication with grunt.

Uploading of built TS+JS can be done by running grunt <world> where <world> can be mmo, private, or local.

Structure

First-class business logic concepts:

  • AI - Root object for the AI
  • Scribe - Aggregates game state and persists room details in case the we lose visibility
  • Caches - Cost Matrices and Path
  • Scheduler - Tracks, schedules, and execute processes
  • Process - A runnable unit for work, wrapper for AI logic run during a tick
  • Topics - Priority queues organized into topics
  • Event Streams - Event streams and consumer groups
  • Tracer - Logging, tracing, and metrics

The AI strategy is contained mostly in the Runnables and the Roles, which will sure the shared constants, functions, and libraries.

Communication between processes and other components is almost entirely done over Topics and Event Streams, items not using these methods are being moved to using them as needed.

Operation

The AI will focus on establishing an economy, build, repair, and defend it's bases. The build manager will spawn at least one Upgrader and will add more if there is energy above the defense reserve.

There are some debugging tools built into the project:

  • Run and draw path - AI.getPathDebugger().debug(new RoomPosition(11, 12, 'W8N4'), new RoomPosition(25,25,'W7N6'), 1, 'warparty')
  • Clear path - AI.getPathDebugger().clear()
  • Run and draw cost matrix - AI.getCostMatrixDebugger().debug("W8N4", 'open_space')
  • Cost matrix clear - AI.getCostMatrixDebugger().clear()
  • Get debug info on path cache - AI.kingdom.getPathCache().debug()
  • Attack a room - AI.getTopics().addRequestV2('attack_room', {priority: 1, details: {status: "requested", roomId: "E58N42"}, ttl: 100})
  • Look at base expansion planning - AI.getBasesDebugger().debug()
  • Look at min cut output - AI.getMinCutDebugger().debug(AI.getKingdom(), 'W6N1')
  • Get cached room details from Scribe - JSON.stringify(AI.getKingdom().getScribe().getRoomById('W8N4'))
  • Launch Nuke - AI.kingdom.sendRequest('nuker_targets', 1, {position: '28,35,E19S49'}, 100)
  • Muster locations AI.getMusterDebugger().debug('W21S34')

There are a couple of helpful global variables:

Many of these persist between restarts, so make sure to unset them when you're finished with them.

  • METRIC_REPORT=true|false - Will output aggregated tracing metric data to the console
  • METRIC_CONSOLE=true|false - Will output tracing metric data to the console
  • METRIC_FILTER=<prefix>|null - Will cause Tracer to report metrics for metrics that start with <prefix>
  • METRIC_MIN=<min ms>|0 - (default 0.5ms) Will cause Tracer to report metrics that are greater than <min ms>
  • LOG_WHEN_PID='<prefix>'|null - Logs with tracers matching the prefix will be output to the console
  • LOG_COLOR=true|false - Will colorize the console output
  • RESET_PIDS=true|false - Will reset the PID controllers - useful when PID controllers are spawning too many haulers

FAQs

Package last updated on 25 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc