Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions src/process/strategy/expand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global PathFinder Room RoomPosition CREEP_LIFE_TIME FIND_MY_CREEPS
TERRAIN_MASK_WALL STRUCTURE_ROAD FIND_CONSTRUCTION_SITES STRUCTURE_RAMPART */

Check failure on line 2 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'STRUCTURE_RAMPART' is defined but never used.

import cache from 'utils/cache';
import container from 'utils/container';
Expand Down Expand Up @@ -44,7 +44,7 @@
expand?: ExpandProcessMemory;
}

namespace NodeJS {

Check failure on line 47 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

ES2015 module syntax is preferred over custom TypeScript modules and namespaces.
interface Global {
ExpandProcess: typeof ExpandProcess;
}
Expand Down Expand Up @@ -74,15 +74,15 @@
constructor(parameters: ProcessParameters) {
super(parameters);

if (!Memory.strategy) {

Check failure on line 77 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe member access .strategy on an `any` value.
Memory.strategy = {};

Check failure on line 78 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe member access .strategy on an `any` value.
}

if (!Memory.strategy.expand) {

Check failure on line 81 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe member access .strategy on an `any` value.
Memory.strategy.expand = {} as ExpandProcessMemory;

Check failure on line 82 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Always prefer const x: T = { ... }.

Check failure on line 82 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe member access .strategy on an `any` value.
}

this.memory = Memory.strategy.expand;

Check failure on line 85 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe member access .strategy on an `any` value.

Check failure on line 85 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe assignment of an `any` value.
this.navMesh = container.get('NavMesh');
this.roomStatus = container.get('RoomStatus');
this.squadManager = container.get('SquadManager');
Expand All @@ -95,7 +95,7 @@
// We probably can't expect to expand earlier than 100 ticks into the game.
if (!stats.getStat('cpu_total', 1000)) return;

Memory.hivemind.canExpand = false;

Check failure on line 98 in src/process/strategy/expand.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unsafe member access .hivemind on an `any` value.
if (!this.memory.currentTarget && this.mayExpand()) {
Memory.hivemind.canExpand = true;
this.chooseNewExpansionTarget();
Expand Down Expand Up @@ -123,6 +123,8 @@
}

mayExpand(): boolean {
if (!settings.get('expand')) return false;

const ownedRooms = interShard.getTotalOwnedRooms();
const hasFreeControlLevels = ownedRooms < Game.gcl.level;
const maxRooms = settings.get('maxOwnedRooms');
Expand Down Expand Up @@ -580,6 +582,8 @@
* Decides if it's worth giving up a weak room in favor of a new expansion.
*/
abandonWeakRooms() {
if (!settings.get('abandon')) return;

// Only abandon rooms if we aren't in the process of expanding.
if (this.memory.currentTarget) return;

Expand Down
2 changes: 2 additions & 0 deletions src/settings-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import localSettings from 'settings.local';

declare global {
type SettingsObject = {
abandon: boolean;
allowBuyingEnergy: boolean;
allowBuyingPixels: boolean;
allowSellingOps: boolean;
Expand All @@ -22,6 +23,7 @@ declare global {
enablePowerMining: boolean;
enableCreatingTradeOrders: boolean;
enableTradeManagement: boolean;
expand: boolean;
expansionMaxRoomDistance: number;
expansionMinRoomDistance: number;
expansionRoomFilter?: (roomName: string) => boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/settings.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const settings: SettingsObject = {
// Expansion:
// Number of ticks we may cache expansion scores.
expansionScoreCacheDuration: 20_000,
abandon: true,
expand: true,
minOwnedRooms: 1,
maxOwnedRooms: null,
// Maximum amount of CPU that may be spent each tick on finding a suitable
Expand Down