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

Fix guard amount for invaderCore attacking #189

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
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
11 changes: 9 additions & 2 deletions src/Overseer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ import {
ROOMTYPE_SOURCEKEEPER
} from './utilities/Cartographer';
import {p} from './utilities/random';
import {canClaimAnotherRoom, getAllRooms, hasJustSpawned, minBy, onPublicServer} from './utilities/utils';
import {
canClaimAnotherRoom,
getAllRooms,
hasJustSpawned,
isRoomAvailable,
minBy,
onPublicServer
} from './utilities/utils';
import {MUON, MY_USERNAME, USE_TRY_CATCH} from './~settings';


Expand Down Expand Up @@ -378,7 +385,7 @@ export class Overseer implements IOverseer {
}
const neighboringRooms = _.values(Game.map.describeExits(roomName)) as string[];
const isReachableFromColony = _.any(neighboringRooms, r => colony.roomNames.includes(r));
return isReachableFromColony && Game.map.isRoomAvailable(roomName);
return isReachableFromColony && isRoomAvailable(roomName);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/overlords/defense/npcDefense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class DefenseNPCOverlord extends Overlord {
}

init() {
const amount = this.room && (this.room.invaders.length > 0 || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0;
const amount = this.room && (this.room.invaders.length > 0 || this.room.invaderCore || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0;
this.wishlist(amount, CombatSetups.broodlings.default, {reassignIdle: true});
}

Expand Down
2 changes: 1 addition & 1 deletion src/overlords/mining/miner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ export class MiningOverlord extends Overlord {
break;
case ERR_NOT_OWNER:
if (Game.time % 20 == 0) {
log.alert(`${miner.print}: room is reserved by hostiles!`);
log.alert(`${miner.print}: room "${miner.room.name}" is reserved by hostiles!`);
}
break;
default:
Expand Down
3 changes: 2 additions & 1 deletion src/overlords/scouting/randomWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Roles, Setups} from '../../creepSetups/setups';
import {OverlordPriority} from '../../priorities/priorities_overlords';
import {profile} from '../../profiler/decorator';
import {Tasks} from '../../tasks/Tasks';
import {isRoomAvailable} from '../../utilities/utils';
import {Zerg} from '../../zerg/Zerg';
import {Overlord} from '../Overlord';

Expand Down Expand Up @@ -40,7 +41,7 @@ export class RandomWalkerScoutOverlord extends Overlord {
// Pick a new room
const neighboringRooms = _.values(Game.map.describeExits(scout.pos.roomName)) as string[];
const roomName = _.sample(neighboringRooms);
if (Game.map.isRoomAvailable(roomName)) {
if (isRoomAvailable(roomName)) {
scout.task = Tasks.goToRoom(roomName);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/roomPlanner/RoadPlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,14 @@ export class RoadPlanner {
/* Clean up leftover road coverage locations from remotes that aren't mined or old structures */
private cleanRoadCoverage() {
const colonyDestinations = this.colony.destinations.map(dest => `${dest.pos.roomName}:${dest.pos.x}:${dest.pos.y}`);
console.log(`Colony ${this.colony.print} has destinations of ${JSON.stringify(colonyDestinations)}`);
log.debug(`Colony ${this.colony.print} has destinations of ${JSON.stringify(colonyDestinations)}`);

for (const roadCoverageKey of Object.keys(this.memory.roadCoverages)) {
// console.log(`Colony ${this.colony.name} Road coverage of ${roadCoverageKey}`);
if (colonyDestinations.includes(roadCoverageKey)) {
// console.log(`Colony has destination of ${roadCoverageKey}`);
} else {
console.log(`Colony does not have destination of ${roadCoverageKey}, deleting.`);
log.warning(`Colony does not have destination of ${roadCoverageKey}, deleting.`);
delete this.memory.roadCoverages[roadCoverageKey];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/strategy/ExpansionPlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Autonomy, getAutonomyLevel, Mem} from '../memory/Memory';
import {Pathing} from '../movement/Pathing';
import {profile} from '../profiler/decorator';
import {Cartographer} from '../utilities/Cartographer';
import {maxBy} from '../utilities/utils';
import {isRoomAvailable, maxBy} from '../utilities/utils';
import {MAX_OWNED_ROOMS, SHARD3_MAX_OWNED_ROOMS} from '../~settings';
import {MIN_EXPANSION_DISTANCE} from './ExpansionEvaluator';

Expand Down Expand Up @@ -123,7 +123,7 @@ export class ExpansionPlanner implements IExpansionPlanner {
}
}
// Update best choices
if (score > bestScore && Game.map.isRoomAvailable(roomName)) {
if (score > bestScore && isRoomAvailable(roomName)) {
bestScore = score;
bestRoom = roomName;
}
Expand Down
7 changes: 7 additions & 0 deletions src/utilities/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,10 @@ export function rotatedMatrix<T>(matrix: T[][], clockwiseTurns: 0 | 1 | 2 | 3):
export function cyclicListPermutation<T>(list: T[], offset: number): T[] {
return list.slice(offset).concat(list.slice(0, offset));
}

export function isRoomAvailable(roomName: string) {
const roomStatus = Game.map.getRoomStatus(roomName);
const expiration = roomStatus.timestamp;
// TODO: cache result and only recheck after expiration
return roomStatus.status === 'normal';
}