Skip to content

Commit

Permalink
Merge pull request #778 from The-International-Screeps-Bot/unstable
Browse files Browse the repository at this point in the history
Stable-ish version
  • Loading branch information
CarsonBurke authored Feb 4, 2024
2 parents 77d54b5 + 38c3e7a commit 42e050c
Show file tree
Hide file tree
Showing 169 changed files with 18,018 additions and 16,631 deletions.
88 changes: 88 additions & 0 deletions DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Overview

This document should outline the design strategies and guidelines for the bot.

The bot intends to implement a primarily data-oriented style, with some aspects of functional, imparative and object oriented design.

# Data/functional structures

## Utils
- a static class
- does not contain any state
- contains functions/methods
- acts on singular inputs

Utils stands for utilities. These are functions that will generally take inputs and provide information in return.

### Example

CommuneUtils contains utility functions that provide often cached information on call that helps with processing

## Procs
- a static class
- does not contain any state
- contains functions/methods
- acts on singular inputs

Procs stands for processors. These are functions that will generally run logic for specified things.

### Example

CommuneProc runs logic for the commune to update data, make intents, and run sub processes like towers, spawning, creeps, etc.

## Ops
- a static class
- does not contain any state
- contains functions/methods
- acts on singular inputs

Ops stands for Operations. These are functions that will run logic for specified things, sometimes retrieving values.

### Example

HaulerNeedOps contians functions that provide cached information, carry out processes, or whatever else.

## Services
- a static class
- does not contain any state
- contains function/methods
- acts on plural inputs

Services run plural inputs, which in turn are generally ran through procs and utils.

### Example

RoomServices contains functions that runs logic for a list of rooms.

## Manager
- a static class
- can contain state
- contains functions/methods
- should generally be avoided given its combination of data and functions, which breaks data-oriented design ideals

Managers can be a combination of utilities, processors and data.

## Data

A state or set of states generally contained in an object. Should not include functions

should probably be opperated on by Procs.

### Example

The MarketManager handles caching market related data, updating / deleting it as needed, while pruning and optimizing existing orders that the bot controls.

## Use of classes

Classes should be static, and static classes should not be instantiated. If a class "needs" to be instantiated, there is probably a better way to do it.

Inherence of classes should be avoided.
classes should no contain state and alter state. They should do only one or the other.

# Creep Tasks

Allows creeps to track general inter-tick actions that are desired for fulfillment

## Task Runners

Task runners decide what actions to take based on the task data provided. Besides running tasks, runners may delete tasks, stop additional tasks to be ran, and more
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ First you'll want to download or fork the repository. Start by selecting a branc

Ensure you have downloaded [Node](https://nodejs.org/en/)

**Consider using Node version is 20.10.0 if you have issues**
**Consider using Node version if 20.10.0 if you have issues**

You can check your node version with:

Expand Down
37 changes: 0 additions & 37 deletions design.md

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "the-international-screeps-bot",
"version": "2.118.0",
"version": "2.119.0",
"description": "",
"files": [
"dist"
Expand Down
108 changes: 56 additions & 52 deletions src/international/constants.ts → src/constants/general.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { packCoord } from 'other/codec'
import { collectiveManager } from './collective'
import { CommuneManager } from 'room/commune/commune'
import { randomIntRange } from 'utils/utils'
import { packCoord } from '../other/codec'
import { randomIntRange } from '../utils/utils'

export enum PlayerRelationships {
ally,
Expand Down Expand Up @@ -150,6 +148,7 @@ export enum SleepFor {
}

export enum CreepMemoryKeys {
commune,
preferRoads,
sourceIndex,
dying,
Expand Down Expand Up @@ -188,26 +187,37 @@ export enum CreepMemoryKeys {
stationary,
defaultParts,
cost,
task,

// Power Creep

powerTask,
}

export enum PowerCreepMemoryKeys {
commune,
/**
* The name of the method queued for operation
*/
task,
taskTarget,
/**
* The type of power the creep should use
*/
taskPower,
taskRoom,
export enum CreepTaskKeys {
taskName,
target,
roomName,
}

export enum PowerRequestKeys {
export enum CreepTaskNames {
// Creep

// harvestMineral,

// Power Creep

advancedGenerateOps,
advancedEnablePower,
advancedRenew,
transferOps,
}

export enum CreepPowerTaskKeys {
taskName,
target,
type,
cooldown,
power,
roomName,
}

export enum RoomTypes {
Expand Down Expand Up @@ -285,6 +295,9 @@ export enum RoomMemoryKeys {
nukeRequest,
threatened,
lastAttackedBy,
/**
* The ideal cost for haulers, not rounded or bounded by the room's spawn energy capacity
*/
minHaulerCost,
minHaulerCostUpdate,
greatestRCL,
Expand Down Expand Up @@ -414,6 +427,11 @@ export const roomTypes: Record<RoomTypes, Set<keyof RoomMemory>> = {
RoomMemoryKeys.dynamicScore,
RoomMemoryKeys.dynamicScoreUpdate,
RoomMemoryKeys.clearedEnemyStructures,
RoomMemoryKeys.workRequest,
RoomMemoryKeys.combatRequests,
RoomMemoryKeys.haulRequests,
RoomMemoryKeys.mineral,
RoomMemoryKeys.greatestRCL,
]),
[RoomTypes.remote]: new Set([
RoomMemoryKeys.commune,
Expand Down Expand Up @@ -539,13 +557,6 @@ export const communeCreepRoles: Set<CreepRoles> = new Set([
'rangedDefender',
])

export enum PowerCreepTasks {
advancedEnablePower,
advancedGenerateOps,
advancedRenew,
transferOps,
}

export const powerCreepClassNames: PowerClassConstant[] = ['operator']

/**
Expand Down Expand Up @@ -606,6 +617,8 @@ export const nonCommuneSigns = [
'Religion is the opium of the people - Karl Marx',
]

export const tauntSign = '✊🛠️'

/**
* What to say when one of our creeps dies
*/
Expand Down Expand Up @@ -743,15 +756,6 @@ export const combatTargetStructureTypes: Set<StructureConstant> = new Set([

export const generalRepairStructureTypes = new Set([STRUCTURE_ROAD, STRUCTURE_CONTAINER])

/**
* These structures have seperate store capacities for different resources. For example, labs can hold minerals and energy, but at different amounts and without conflict
*/
export const separateStoreStructureTypes = new Set<StructureConstant>([
STRUCTURE_LAB,
STRUCTURE_NUKER,
STRUCTURE_POWER_SPAWN,
])

export const customColors = {
white: '#ffffff',
lightGrey: '#eaeaea',
Expand Down Expand Up @@ -1013,12 +1017,12 @@ export const antifaRoles: (
| 'antifaDismantler'
| 'antifaDowngrader'
)[] = [
'antifaRangedAttacker',
'antifaAttacker',
'antifaHealer',
'antifaDismantler',
'antifaDowngrader',
]
'antifaRangedAttacker',
'antifaAttacker',
'antifaHealer',
'antifaDismantler',
'antifaDowngrader',
]

/**
* Roles for which to provide spawnGroups for based on their shared remoteName
Expand All @@ -1044,17 +1048,6 @@ export const relayRoles: Set<CreepRoles> = new Set(['hauler'])
*/
export const cacheAmountModifier = 25

/**
* Which structures should be safemoded when attacked
*/
export const safemodeTargets: StructureConstant[] = [
STRUCTURE_SPAWN,
STRUCTURE_TOWER,
STRUCTURE_STORAGE,
STRUCTURE_TERMINAL,
]
export const safemodeTargetsSet = new Set(safemodeTargets)

/**
* The number of ticks to wait between hauler size updates
*/
Expand Down Expand Up @@ -1322,6 +1315,7 @@ export enum RoomStatsKeys {
EnergyOutputTransactionCosts = 'eotc',
EnergyTerminalSentDomestic = 'etsd',
EnergyTerminalSentOther = 'etso',
CpuUsed = 'cpu',

GameTime = 'gt',
RemoteCount = 'rc',
Expand Down Expand Up @@ -1470,6 +1464,16 @@ export enum FlagNames {
debugRoomLogistics = 'debugRoomLogistics',
debugCreepLogistics = 'debugCreepLogistics',
debugSpawning = 'debugSpawning',
mapVisuals = 'mapVisuals',
roomVisuals = 'roomVisuals',
deactivate = 'deactiveate',
}

export const IDUpdateInterval = randomIntRange(50, 100)

export const creepDamageEvents = new Set([
EVENT_ATTACK_TYPE_MELEE,
EVENT_ATTACK_TYPE_DISMANTLE,
EVENT_ATTACK_TYPE_RANGED,
EVENT_ATTACK_TYPE_RANGED_MASS,
])
8 changes: 8 additions & 0 deletions src/constants/structures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* These structures have seperate store capacities for different resources. For example, labs can hold minerals and energy, but at different amounts and without conflict
*/
export const separateStoreStructureTypes = new Set<StructureConstant>([
STRUCTURE_LAB,
STRUCTURE_NUKER,
STRUCTURE_POWER_SPAWN,
])
Loading

0 comments on commit 42e050c

Please sign in to comment.