diff --git a/src/declarations/memory.d.ts b/src/declarations/memory.d.ts index 22b85a301..4e3b46908 100644 --- a/src/declarations/memory.d.ts +++ b/src/declarations/memory.d.ts @@ -30,6 +30,7 @@ interface Memory { haltTick?: number; combatPlanner: any; reinforcementLearning?: any; + zoneRooms: { [roomName: string]: { [type: string]: number} }; [otherProperty: string]: any; } diff --git a/src/intel/RoomIntel.ts b/src/intel/RoomIntel.ts index c9046ed45..68098d50d 100644 --- a/src/intel/RoomIntel.ts +++ b/src/intel/RoomIntel.ts @@ -7,6 +7,8 @@ import {ExpansionEvaluator} from '../strategy/ExpansionEvaluator'; import {getCacheExpiration, irregularExponentialMovingAverage} from '../utilities/utils'; import {Zerg} from '../zerg/Zerg'; import {MY_USERNAME} from '../~settings'; +import {Segmenter} from "../memory/Segmenter"; +import {log} from "../console/log"; const RECACHE_TIME = 2500; const OWNED_RECACHE_TIME = 1000; @@ -351,9 +353,25 @@ export class RoomIntel { return 0; } + static requestZoneData() { + const checkOnTick = 123; + if (Game.time % 1000 == checkOnTick - 2) { + Segmenter.requestForeignSegment('LeagueOfAutomatedNations', 96); + } else if (Game.time % 1000 == checkOnTick - 1 ) { + const loanData = Segmenter.getForeignSegment(); + if (loanData) { + Memory.zoneRooms = loanData; + } else { + log.error('Empty LOAN data'); + } + } + } + static run(): void { let alreadyComputedScore = false; + this.requestZoneData(); + for (const name in Game.rooms) { const room: Room = Game.rooms[name]; diff --git a/src/utilities/Cartographer.ts b/src/utilities/Cartographer.ts index 92d576a1a..f03b3bb8d 100644 --- a/src/utilities/Cartographer.ts +++ b/src/utilities/Cartographer.ts @@ -1,4 +1,5 @@ import {profile} from '../profiler/decorator'; +import {log} from "../console/log"; export const ROOMTYPE_SOURCEKEEPER = 'SK'; export const ROOMTYPE_CORE = 'CORE'; @@ -214,4 +215,24 @@ export class Cartographer { }; } + static isNoviceRoom(roomName: string): boolean { + if (Memory.zoneRooms) { + const roomInfo = Memory.zoneRooms[roomName]; + return !!roomInfo && !!roomInfo['novice']; + } else { + log.alert(`Checking novice room before segment is set in ${roomName}!`); + return false; + } + } + + static isRespawnRoom(roomName: string): boolean { + if (Memory.zoneRooms) { + const roomInfo = Memory.zoneRooms[roomName]; + return !!roomInfo && !!roomInfo['respawnArea']; + } else { + log.alert(`Checking respawn room before segment is set in ${roomName}!`); + return false; + } + } + }