Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable-ish version #778

Merged
merged 63 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4ecc2b2
optimize funneling, fastFillerCoords finding
CarsonBurke Jan 21, 2024
f6589b5
(migration) smarter room status access + recording
CarsonBurke Jan 21, 2024
afb21f5
update util and proc descriptions
CarsonBurke Jan 23, 2024
eb2eb2c
record main run commune cpu usage
CarsonBurke Jan 23, 2024
59b051d
upgrade simpleAllies, static rework start
CarsonBurke Jan 23, 2024
ae937e2
more static conversion, basic scheduler structure
CarsonBurke Jan 23, 2024
b66a3a4
more static conversions, scheduler additions
CarsonBurke Jan 23, 2024
651cd0d
organization and static util conversion
CarsonBurke Jan 23, 2024
63786fd
data managers -> procs, .data -> seperate data obj
CarsonBurke Jan 23, 2024
ba272a8
static creepMoveProcs
CarsonBurke Jan 23, 2024
69038cd
static CreepProcs
CarsonBurke Jan 23, 2024
26a3299
static CreepUtils, LogisticsProcs
CarsonBurke Jan 23, 2024
958643f
static structureUtils
CarsonBurke Jan 23, 2024
e7c5000
more static conversions
CarsonBurke Jan 23, 2024
23b589e
static SpawnRequestConstructors, MemoryHack
CarsonBurke Jan 23, 2024
7bc38e8
static ErrorExporter, SpawningStructureProcs
CarsonBurke Jan 23, 2024
2e5e396
many more static conversions
CarsonBurke Jan 23, 2024
1bdd849
completed static conversion for viable classes?
CarsonBurke Jan 23, 2024
f09b4ec
defence procs/utils, static CommuneUtils
CarsonBurke Jan 23, 2024
2d095ea
minor lab code improvements
CarsonBurke Jan 23, 2024
1d73cbd
downgrader, core attacker priority adjustments
CarsonBurke Jan 23, 2024
c21ec30
CommuneProcs, RoomProcs more services from respective managers
CarsonBurke Jan 24, 2024
52ed93a
(migration) creep task improvements, fastFillerCoords new usage, gene…
CarsonBurke Jan 28, 2024
3533a3b
clean up CustomPathFinder room weights
CarsonBurke Jan 28, 2024
a360846
more CustomPathFinder cleaning
CarsonBurke Jan 28, 2024
0812f2b
powerTasks, internal garbage collection fixes
CarsonBurke Jan 29, 2024
e016e37
fix operation spelling mistake
CarsonBurke Jan 30, 2024
068807c
clean up code, introduce ops
CarsonBurke Jan 30, 2024
7f39768
clarify ops purpose
CarsonBurke Jan 30, 2024
4971045
creep and power creep services
CarsonBurke Jan 30, 2024
247984e
new hauler role proc logic
CarsonBurke Jan 30, 2024
4daee7a
haulerProcs -> haulerOps
CarsonBurke Jan 30, 2024
2368b95
new roles cleanup
CarsonBurke Jan 30, 2024
cfecb34
correct references to improved stat keys enum
CarsonBurke Jan 30, 2024
b308b4d
RoomDataProcs -> RoomDataOps; CommuneDataProcs -> CommuneDataOps
CarsonBurke Jan 30, 2024
4318b82
cached and uncached terrain binary options, optimize calls to them
CarsonBurke Jan 30, 2024
f8cc547
Correctly rename RoomProcs file -> RoomOps
CarsonBurke Jan 30, 2024
e983084
Fix roomOps file name
CarsonBurke Jan 30, 2024
87916e5
+getStructures
CarsonBurke Jan 30, 2024
31de793
patch easy to patch holes in RoomMamanger, CommuneManager
CarsonBurke Jan 30, 2024
a94d99e
deletion of roomData, communeData object on largest deletion interval
CarsonBurke Jan 30, 2024
98e94bb
remove deprecated freeSpecificStore
CarsonBurke Jan 30, 2024
b25b954
delete deprecated roomVisuals, mapVisuals settings
CarsonBurke Jan 30, 2024
88385f6
new setup for Antifa logic
CarsonBurke Jan 30, 2024
7f5a377
constants in seperate folder
CarsonBurke Jan 31, 2024
0340236
clarify DESIGN.md
CarsonBurke Jan 31, 2024
e2add20
fix spelling error readme.md
CarsonBurke Jan 31, 2024
8c01424
CommuneProcs -> CommuneOps
CarsonBurke Jan 31, 2024
1d16409
👁️ where will this push?
realacesu Jan 31, 2024
aa4530f
Revert "👁️ where will this push?"
realacesu Jan 31, 2024
542b39a
🚧 notMyCreeps.invader
realacesu Jan 31, 2024
4276e17
solve complier problem with various other errors
realacesu Jan 31, 2024
709e549
import consants/structures
CarsonBurke Feb 3, 2024
f83a85b
remove roomObjectAdditions import
CarsonBurke Feb 3, 2024
277472c
Merge pull request #775 from realacesu/unstable
CarsonBurke Feb 3, 2024
732b871
merge
CarsonBurke Feb 3, 2024
e3f1ef7
Merge remote branch 'origin/unstable'
CarsonBurke Feb 3, 2024
1d7bc44
fix constant replanning
CarsonBurke Feb 3, 2024
0e4714b
correct references to DebugUtils
CarsonBurke Feb 3, 2024
61b9351
organize and potentially fix scouting
CarsonBurke Feb 3, 2024
6710176
general stability fixes
CarsonBurke Feb 4, 2024
35a928f
general improvements, logistics request swapping fix
CarsonBurke Feb 4, 2024
38c3e7a
additional hauler relaying and logistics fixes
CarsonBurke Feb 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading