From 3473b8e81e6af377d978ddd4db0604ba6bb8db29 Mon Sep 17 00:00:00 2001 From: Matthew Roy Date: Fri, 7 Jun 2019 12:01:48 -0700 Subject: [PATCH 1/5] Adding zone data fetch --- src/intel/RoomIntel.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/intel/RoomIntel.ts b/src/intel/RoomIntel.ts index c9046ed45..3c4812130 100644 --- a/src/intel/RoomIntel.ts +++ b/src/intel/RoomIntel.ts @@ -7,6 +7,7 @@ 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"; const RECACHE_TIME = 2500; const OWNED_RECACHE_TIME = 1000; @@ -351,6 +352,16 @@ export class RoomIntel { return 0; } + static requestZoneData() { + const checkOnTick = 12; + if (Game.time % 30 == checkOnTick - 2) { + Segmenter.requestForeignSegment('LOAN', 96); + } else if (Game.time % 30 == checkOnTick - 1) { + const loanData = Segmenter.getForeignSegment(); + console.log(`\n \n \n \n Loan Data is: ${loanData} \n \n \n \n `); + } + } + static run(): void { let alreadyComputedScore = false; @@ -360,6 +371,7 @@ export class RoomIntel { this.markVisible(room); this.recordSafety(room); + this.requestZoneData(); // Track invasion data, harvesting, and casualties for all colony rooms and outposts if (Overmind.colonyMap[room.name]) { // if it is an owned or outpost room From 11551359c6edc3fcb3ffccb424a39a5001191434 Mon Sep 17 00:00:00 2001 From: Matthew Roy Date: Fri, 7 Jun 2019 12:28:54 -0700 Subject: [PATCH 2/5] Adding to memory and printing --- src/declarations/memory.d.ts | 1 + src/intel/RoomIntel.ts | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/declarations/memory.d.ts b/src/declarations/memory.d.ts index 22b85a301..4a603e0c3 100644 --- a/src/declarations/memory.d.ts +++ b/src/declarations/memory.d.ts @@ -31,6 +31,7 @@ interface Memory { 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 3c4812130..efc699a66 100644 --- a/src/intel/RoomIntel.ts +++ b/src/intel/RoomIntel.ts @@ -353,25 +353,34 @@ export class RoomIntel { } static requestZoneData() { - const checkOnTick = 12; - if (Game.time % 30 == checkOnTick - 2) { - Segmenter.requestForeignSegment('LOAN', 96); - } else if (Game.time % 30 == checkOnTick - 1) { + const checkOnTick = 4; + if (Game.time % 10 == checkOnTick - 2) { + Segmenter.requestForeignSegment('LeagueOfAutomatedNations', 96); + } else if (Game.time % 10 == checkOnTick - 1 || Game.time % 10 == checkOnTick) { const loanData = Segmenter.getForeignSegment(); - console.log(`\n \n \n \n Loan Data is: ${loanData} \n \n \n \n `); + if (loanData) { + console.log(`\n \n \n \n Loan Data is: ${JSON.stringify(loanData)} \n \n \n \n `); + } else { + console.log('Empty loan data'); + } } } static run(): void { let alreadyComputedScore = false; + this.requestZoneData(); + for (const name in Game.rooms) { const room: Room = Game.rooms[name]; + if (Memory.zoneRooms && _.keys(Memory.zoneRooms).indexOf(name) != -1) { + console.log(`Room ${name} found in zone! ${Memory.zoneRooms[name]}`); + } + this.markVisible(room); this.recordSafety(room); - this.requestZoneData(); // Track invasion data, harvesting, and casualties for all colony rooms and outposts if (Overmind.colonyMap[room.name]) { // if it is an owned or outpost room From 2e9e38776c5830d13452c82493829d65eaba99c3 Mon Sep 17 00:00:00 2001 From: Matthew Roy Date: Fri, 7 Jun 2019 13:23:21 -0700 Subject: [PATCH 3/5] Adding storage and utils for checking --- src/intel/RoomIntel.ts | 11 ++++++----- src/utilities/Cartographer.ts | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/intel/RoomIntel.ts b/src/intel/RoomIntel.ts index efc699a66..6161989da 100644 --- a/src/intel/RoomIntel.ts +++ b/src/intel/RoomIntel.ts @@ -8,6 +8,7 @@ import {getCacheExpiration, irregularExponentialMovingAverage} from '../utilitie 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; @@ -353,15 +354,15 @@ export class RoomIntel { } static requestZoneData() { - const checkOnTick = 4; - if (Game.time % 10 == checkOnTick - 2) { + const checkOnTick = 123; + if (Game.time % 1000 == checkOnTick - 2) { Segmenter.requestForeignSegment('LeagueOfAutomatedNations', 96); - } else if (Game.time % 10 == checkOnTick - 1 || Game.time % 10 == checkOnTick) { + } else if (Game.time % 1000 == checkOnTick - 1 ) { const loanData = Segmenter.getForeignSegment(); if (loanData) { - console.log(`\n \n \n \n Loan Data is: ${JSON.stringify(loanData)} \n \n \n \n `); + Memory.zoneRooms = loanData; } else { - console.log('Empty loan data'); + log.error('Empty LOAN data'); } } } diff --git a/src/utilities/Cartographer.ts b/src/utilities/Cartographer.ts index 92d576a1a..c23877ba2 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; + } + } + } From 5a3e518e08085157d0e3f9ad121813233423cbbb Mon Sep 17 00:00:00 2001 From: Matthew Roy Date: Fri, 7 Jun 2019 13:31:19 -0700 Subject: [PATCH 4/5] !! for false --- src/utilities/Cartographer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utilities/Cartographer.ts b/src/utilities/Cartographer.ts index c23877ba2..f03b3bb8d 100644 --- a/src/utilities/Cartographer.ts +++ b/src/utilities/Cartographer.ts @@ -218,7 +218,7 @@ export class Cartographer { static isNoviceRoom(roomName: string): boolean { if (Memory.zoneRooms) { const roomInfo = Memory.zoneRooms[roomName]; - return roomInfo && !!roomInfo['novice']; + return !!roomInfo && !!roomInfo['novice']; } else { log.alert(`Checking novice room before segment is set in ${roomName}!`); return false; @@ -228,7 +228,7 @@ export class Cartographer { static isRespawnRoom(roomName: string): boolean { if (Memory.zoneRooms) { const roomInfo = Memory.zoneRooms[roomName]; - return roomInfo && !!roomInfo['respawnArea']; + return !!roomInfo && !!roomInfo['respawnArea']; } else { log.alert(`Checking respawn room before segment is set in ${roomName}!`); return false; From 96992ecb13612792b9c0f8730c0b6988af823c9c Mon Sep 17 00:00:00 2001 From: Matthew Roy Date: Fri, 7 Jun 2019 13:33:31 -0700 Subject: [PATCH 5/5] PR logging cleanup --- src/declarations/memory.d.ts | 2 +- src/intel/RoomIntel.ts | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/declarations/memory.d.ts b/src/declarations/memory.d.ts index 4a603e0c3..4e3b46908 100644 --- a/src/declarations/memory.d.ts +++ b/src/declarations/memory.d.ts @@ -30,8 +30,8 @@ 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 6161989da..68098d50d 100644 --- a/src/intel/RoomIntel.ts +++ b/src/intel/RoomIntel.ts @@ -376,10 +376,6 @@ export class RoomIntel { const room: Room = Game.rooms[name]; - if (Memory.zoneRooms && _.keys(Memory.zoneRooms).indexOf(name) != -1) { - console.log(`Room ${name} found in zone! ${Memory.zoneRooms[name]}`); - } - this.markVisible(room); this.recordSafety(room);