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

Add Assimilation checks to Colonization #115

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
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
35 changes: 25 additions & 10 deletions src/directives/colony/colonize.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {profile} from '../../profiler/decorator';
import {Directive} from '../Directive';
import {ClaimingOverlord} from '../../overlords/colonization/claimer';
import {Colony} from '../../Colony';
import {PioneerOverlord} from '../../overlords/colonization/pioneer';
import {MY_USERNAME} from '../../~settings';
import {log} from '../../console/log';
import {Roles} from '../../creepSetups/setups';
import {Cartographer, ROOMTYPE_CONTROLLER} from '../../utilities/Cartographer';
import {printRoomName} from '../../utilities/utils';
import { Colony } from '../../Colony';
import { log } from '../../console/log';
import { Roles } from '../../creepSetups/setups';
import { RoomIntel } from '../../intel/RoomIntel';
import { ClaimingOverlord } from '../../overlords/colonization/claimer';
import { PioneerOverlord } from '../../overlords/colonization/pioneer';
import { profile } from '../../profiler/decorator';
import { Cartographer, ROOMTYPE_CONTROLLER } from '../../utilities/Cartographer';
import { printRoomName } from '../../utilities/utils';
import { MY_USERNAME } from '../../~settings';
import { Directive } from '../Directive';


/**
Expand Down Expand Up @@ -67,6 +68,20 @@ export class DirectiveColonize extends Directive {
// Remove the directive
this.remove();
}

// if reserved or owned by Overmind user - throw warning but don't remove? Included code to remove, just commented out.
let AssimilatedRoomOwner = (typeof RoomIntel.roomOwnedBy(this.pos.roomName) === 'string' && RoomIntel.roomOwnedBy(this.pos.roomName) != MY_USERNAME && Assimilator.isAssimilated(RoomIntel.roomOwnedBy(this.pos.roomName)!))
let AssimilatedRoomReserved = (typeof RoomIntel.roomReservedBy(this.pos.roomName) === 'string' && RoomIntel.roomReservedBy(this.pos.roomName) != MY_USERNAME && Assimilator.isAssimilated(RoomIntel.roomReservedBy(this.pos.roomName)!))
//log.debug(`${this.print} Owned by: ${RoomIntel.roomOwnedBy(this.pos.roomName)}, who is ${AssimilatedRoomOwner} Assimilated. Reserved by: ${RoomIntel.roomReservedBy(this.pos.roomName)}, who is ${AssimilatedRoomReserved} Assimilated`)
if (Game.time % 10 == 2 && AssimilatedRoomOwner) {
log.warning(`${this.print} is in a room controlled by another Overmind user ${RoomIntel.roomOwnedBy(this.pos.roomName)}!`)
//this.remove();
}
else if (Game.time % 10 == 2 && AssimilatedRoomReserved) {
log.warning(`${this.print} is in a room controlled by another Overmind user ${RoomIntel.roomReservedBy(this.pos.roomName)}!`)
//this.remove();
}

if (Game.time % 10 == 2 && this.room && !!this.room.owner && this.room.owner != MY_USERNAME) {
log.notify(`Removing Colonize directive in ${this.pos.roomName}: room already owned by another player.`);
this.remove();
Expand Down
26 changes: 21 additions & 5 deletions src/directives/colony/incubate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {profile} from '../../profiler/decorator';
import {Directive} from '../Directive';
import {ClaimingOverlord} from '../../overlords/colonization/claimer';
import {Colony} from '../../Colony';
import {SpawnGroup} from '../../logistics/SpawnGroup';
import { Colony } from '../../Colony';
import { log } from '../../console/log';
import { RoomIntel } from '../../intel/RoomIntel';
import { SpawnGroup } from '../../logistics/SpawnGroup';
import { ClaimingOverlord } from '../../overlords/colonization/claimer';
import { profile } from '../../profiler/decorator';
import { Directive } from '../Directive';
import { MY_USERNAME } from '../../~settings';


/**
Expand Down Expand Up @@ -43,5 +46,18 @@ export class DirectiveIncubate extends Directive {
this.remove();
}
}

// if reserved or owned by Overmind user - throw warning but don't remove? Included code to remove, just commented out.
let AssimilatedRoomOwner = (typeof RoomIntel.roomOwnedBy(this.pos.roomName) === 'string' && RoomIntel.roomOwnedBy(this.pos.roomName) != MY_USERNAME && Assimilator.isAssimilated(RoomIntel.roomOwnedBy(this.pos.roomName)!))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example:

let roomOwner = RoomIntel.roomOwnedBy(this.pos.roomName);
let NonConflictRoomOwner = (typeof roomOwner === 'string' && roomOwner != MY_USERNAME && (getAggressionLevel() == Aggression.LOW || Assimilator.isAssimilated(roomOwner!)));

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, it could be renamed from isAssimilated to isFriendly, which checks if you are set non-conflict and have not blacklisted them (enemy list), or if they are assimilated/on your whitelist (allies)

let AssimilatedRoomReserved = (typeof RoomIntel.roomReservedBy(this.pos.roomName) === 'string' && RoomIntel.roomReservedBy(this.pos.roomName) != MY_USERNAME && Assimilator.isAssimilated(RoomIntel.roomReservedBy(this.pos.roomName)!))
//log.debug(`${this.print} Owned by: ${RoomIntel.roomOwnedBy(this.pos.roomName)}, who is ${AssimilatedRoomOwner} Assimilated. Reserved by: ${RoomIntel.roomReservedBy(this.pos.roomName)}, who is ${AssimilatedRoomReserved} Assimilated`)
if (Game.time % 10 == 2 && AssimilatedRoomOwner) {
log.warning(`${this.print} is in a room controlled by another Overmind user ${RoomIntel.roomOwnedBy(this.pos.roomName)}!`)
//this.remove();
}
else if (Game.time % 10 == 2 && AssimilatedRoomReserved) {
log.warning(`${this.print} is in a room controlled by another Overmind user ${RoomIntel.roomReservedBy(this.pos.roomName)}!`)
//this.remove();
}
}
}
29 changes: 22 additions & 7 deletions src/directives/colony/outpost.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {Directive} from '../Directive';
import {profile} from '../../profiler/decorator';
import {ReservingOverlord} from '../../overlords/colonization/reserver';
import {StationaryScoutOverlord} from '../../overlords/scouting/stationary';
import {Cartographer, ROOMTYPE_CONTROLLER} from '../../utilities/Cartographer';
import {RoomIntel} from '../../intel/RoomIntel';
import {log} from '../../console/log';
import { MY_USERNAME } from '../../~settings';
import { log } from '../../console/log';
import { RoomIntel } from '../../intel/RoomIntel';
import { ReservingOverlord } from '../../overlords/colonization/reserver';
import { StationaryScoutOverlord } from '../../overlords/scouting/stationary';
import { profile } from '../../profiler/decorator';
import { Cartographer, ROOMTYPE_CONTROLLER } from '../../utilities/Cartographer';
import { Directive } from '../Directive';

/**
* Claims a new room and incubates it from the nearest (or specified) colony
Expand Down Expand Up @@ -39,6 +40,20 @@ export class DirectiveOutpost extends Directive {
log.warning(`Removing ${this.print} since room is owned!`);
this.remove();
}

// if reserved or owned by Overmind user - throw warning but don't remove? Included code to remove, just commented out.
let AssimilatedRoomOwner = (typeof RoomIntel.roomOwnedBy(this.pos.roomName) === 'string' && RoomIntel.roomOwnedBy(this.pos.roomName) != MY_USERNAME && Assimilator.isAssimilated(RoomIntel.roomOwnedBy(this.pos.roomName)!))
let AssimilatedRoomReserved = (typeof RoomIntel.roomReservedBy(this.pos.roomName) === 'string' && RoomIntel.roomReservedBy(this.pos.roomName) != MY_USERNAME && Assimilator.isAssimilated(RoomIntel.roomReservedBy(this.pos.roomName)!))
//log.debug(`${this.print} Owned by: ${RoomIntel.roomOwnedBy(this.pos.roomName)}, who is ${AssimilatedRoomOwner} Assimilated. Reserved by: ${RoomIntel.roomReservedBy(this.pos.roomName)}, who is ${AssimilatedRoomReserved} Assimilated`)
if (Game.time % 10 == 2 && AssimilatedRoomOwner) {
log.warning(`${this.print} is in a room controlled by another Overmind user ${RoomIntel.roomOwnedBy(this.pos.roomName)}!`)
//this.remove();
}
else if (Game.time % 10 == 2 && AssimilatedRoomReserved) {
log.warning(`${this.print} is in a room controlled by another Overmind user ${RoomIntel.roomReservedBy(this.pos.roomName)}!`)
//this.remove();
}

if (Game.time % 10 == 3 && this.room && this.room.controller
&& !this.pos.isEqualTo(this.room.controller.pos) && !this.memory.setPosition) {
this.setPosition(this.room.controller.pos);
Expand Down
29 changes: 18 additions & 11 deletions src/strategy/Strategist.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Autonomy, getAutonomyLevel, Mem} from '../memory/Memory';
import {Colony, getAllColonies} from '../Colony';
import {DirectiveColonize} from '../directives/colony/colonize';
import {Cartographer} from '../utilities/Cartographer';
import {MIN_EXPANSION_DISTANCE} from './ExpansionPlanner';
import {maxBy} from '../utilities/utils';
import {log} from '../console/log';
import {Pathing} from '../movement/Pathing';
import {assimilationLocked} from '../assimilation/decorator';
import {MAX_OWNED_ROOMS, SHARD3_MAX_OWNED_ROOMS} from '../~settings';
import {profile} from '../profiler/decorator';
import { Colony, getAllColonies } from '../Colony';
import { assimilationLocked } from '../assimilation/decorator';
import { log } from '../console/log';
import { DirectiveColonize } from '../directives/colony/colonize';
import { Autonomy, Mem, getAutonomyLevel } from '../memory/Memory';
import { Pathing } from '../movement/Pathing';
import { profile } from '../profiler/decorator';
import { Cartographer } from '../utilities/Cartographer';
import { maxBy } from '../utilities/utils';
import { MAX_OWNED_ROOMS, MY_USERNAME, SHARD3_MAX_OWNED_ROOMS } from '../~settings';
import { MIN_EXPANSION_DISTANCE } from './ExpansionPlanner';


const CHECK_EXPANSION_FREQUENCY = 1000;
Expand Down Expand Up @@ -114,6 +114,13 @@ export class Strategist implements IStrategist {
if (_.any(adjacentRooms, roomName => Memory.rooms[roomName][_RM.AVOID])) {
continue;
}

// Are there other Overmind users nearby?
if (_.any(adjacentRooms, roomName => typeof Game.rooms[roomName].owner === 'string' && Game.rooms[roomName].owner != MY_USERNAME && Assimilator.isAssimilated(Game.rooms[roomName].owner!))) {
score -= TOO_CLOSE_PENALTY;
log.debug(`Strategist triggered too close to overmind user ${Game.rooms[roomName].owner} for ${roomName}`)
}

// Reward new minerals and catalyst rooms
let mineralType = Memory.rooms[roomName][_RM.MINERAL]
? Memory.rooms[roomName][_RM.MINERAL]![_RM_MNRL.MINERALTYPE]
Expand Down