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

funneling and power creep task fixes #794

Merged
merged 1 commit into from
May 25, 2024
Merged
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
6 changes: 5 additions & 1 deletion src/international/collective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,13 @@ export class CollectiveManager {

static getFunnelingRoomNames() {

const funnelTargets = new Set<string>()
// How much energy we are allowed to distribute each tick of funneling
let funnelDistribution = 0
const funnelTargetQuotas: { [roomName: string]: number } = {}

const funnelOrder = this.getFunnelOrder()

const funnelTargets = new Set<string>()
funnelTargets.add(funnelOrder[0])

for (const roomName of funnelOrder) {
Expand All @@ -370,6 +371,8 @@ export class CollectiveManager {
funnelDistribution += desiredStrength - maxUpgradeStrength
continue
}
// If we are RCL 8, no need for us to get funneled
if (room.controller.level === 8) continue

funnelTargetQuotas[roomName] = maxUpgradeStrength
}
Expand All @@ -378,6 +381,7 @@ export class CollectiveManager {
LogOps.log('Funnel quotas', `distribution: ${funnelDistribution}, quotas: ${JSON.stringify(funnelTargetQuotas)}`, { type: LogTypes.debug })
}

if (Object.keys(funnelTargetQuotas).length === 0) return new Set<string>();
if (funnelDistribution === 0) return funnelTargets

for (const roomName in funnelTargetQuotas) {
Expand Down
2 changes: 1 addition & 1 deletion src/room/commune/spawning/spawnRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ export class SpawnRequestsManager {
// If there is a terminal and it is sufficient RCL, and there's a funnel target and we aren't it, then don't allow upgraders to spawn
if (this.communeManager.room.terminal && this.communeManager.room.controller.level >= 6) {
const funnelingRoomNames = CollectiveManager.getFunnelingRoomNames()
if (!funnelingRoomNames.has(this.communeManager.room.name)) {
if (funnelingRoomNames.size > 0 && !funnelingRoomNames.has(this.communeManager.room.name)) {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/room/creeps/powerCreeps/operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export class Operator extends PowerCreep {
//

this.powered = true
delete Memory.powerCreeps[CreepMemoryKeys.powerTask]
delete Memory.powerCreeps[this.name][CreepMemoryKeys.powerTask]

return Result.success
}
Expand Down
1 change: 1 addition & 0 deletions src/room/remotePlanner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import {
CPUMaxPerTick,
defaultRoadPlanningPlainCost,
Expand Down
9 changes: 8 additions & 1 deletion src/room/roomNameUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,16 @@ export class RoomNameUtils {
const searchRoom = Game.rooms[searchRoomName]
if (!searchRoom) return

const distance = this.advancedFindDistance(roomName, searchRoomName)

if (distance === 1) {
communeScore = 10000
return
}

const score =
Math.pow(
Math.abs(this.advancedFindDistance(roomName, searchRoomName) - preferredCommuneRange),
Math.abs(distance - preferredCommuneRange),
1.8,
) +
(maxControllerLevel - searchRoom.controller.level)
Expand Down
Loading