Skip to content

Commit

Permalink
Roadplanner won't plan incomplete paths; image updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bencbartlett committed May 15, 2018
1 parent 89b6347 commit 4ccb272
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
Binary file added assets/img/Muon_512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/img/OvermindIcon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/img/OvermindIcon.psd
Binary file not shown.
Binary file modified assets/img/OvermindLogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/img/OvermindLogo.psd
Binary file not shown.
2 changes: 1 addition & 1 deletion src/hiveClusters/hiveCluster_upgradeSite.ts
Expand Up @@ -42,7 +42,7 @@ export class UpgradeSite extends HiveCluster {
let allowableContainers = _.filter(this.room.containers, container =>
container.pos.findInRange(FIND_SOURCES, 1).length == 0); // only count containers that aren't near sources
this.battery = this.pos.findClosestByLimitedRange(allowableContainers, 3);
this.link = this.pos.findClosestByLimitedRange(colony.links, 3);
this.link = this.pos.findClosestByLimitedRange(colony.links, 4);
// Register input construction sites
let nearbyInputSites = this.pos.findInRange(this.room.structureSites, 4, {
filter: (s: ConstructionSite) => s.structureType == STRUCTURE_CONTAINER ||
Expand Down
14 changes: 10 additions & 4 deletions src/roomPlanner/RoadPlanner.ts
Expand Up @@ -72,8 +72,10 @@ export class RoadPlanner {
private planRoad(pos1: RoomPosition, pos2: RoomPosition, obstacles: RoomPosition[]): void {
let opts = {obstacles: obstacles, ensurePath: true, range: 1};
// Find the shortest path, preferentially stepping on tiles with road routing flags on them
let roadPath = this.generateRoadPath(pos1, pos2, opts).path;
this.roadPositions = this.roadPositions.concat(roadPath);
let roadPath = this.generateRoadPath(pos1, pos2, opts);
if (roadPath) {
this.roadPositions = this.roadPositions.concat(roadPath);
}
}

private initCostMatrix(roomName: string, options: TravelToOptions) {
Expand All @@ -98,7 +100,7 @@ export class RoadPlanner {

/* Generates a road path and modifies cost matrices to encourage merging with future roads */
private generateRoadPath(origin: RoomPosition, destination: RoomPosition,
options: TravelToOptions = {}): PathfinderReturn {
options: TravelToOptions = {}): RoomPosition[] | undefined {
_.defaults(options, {
ignoreCreeps: true,
ensurePath : true,
Expand Down Expand Up @@ -146,6 +148,10 @@ export class RoadPlanner {
swampCost : 2,
roomCallback: callback,
});

if (ret.incomplete) {
return;
}
// Set every n-th tile of a planned path to be cost 1 to encourage road overlap for future pathing
if (RoadPlanner.settings.encourageRoadMerging) {
let interval = RoadPlanner.settings.tileCostReductionInterval;
Expand All @@ -159,7 +165,7 @@ export class RoadPlanner {
}
}
// Return the pathfinder results
return ret;
return ret.path;
}

/* Ensure that the roads doesn't overlap with roads from this.map and that the positions are unique */
Expand Down
8 changes: 1 addition & 7 deletions src/tasks/Tasks.ts
@@ -1,7 +1,6 @@
import {attackTargetType, TaskAttack} from './task_attack';
import {buildTargetType, TaskBuild} from './task_build';
import {claimTargetType, TaskClaim} from './task_claim';
// import {depositTargetType, TaskDeposit} from './task_deposit';
import {dismantleTargetType, TaskDismantle} from './task_dismantle';
import {fortifyTargetType, TaskFortify} from './task_fortify';
import {getBoostedTargetType, TaskGetBoosted} from './task_getBoosted';
Expand All @@ -19,12 +18,11 @@ import {signControllerTargetType, TaskSignController} from './task_signControlle
import {TaskTransfer, transferTargetType} from './task_transfer';
import {TaskUpgrade, upgradeTargetType} from './task_upgrade';
import {TaskWithdraw, withdrawTargetType} from './task_withdraw';
// import {TaskWithdrawResource, withdrawResourceTargetType} from './task_withdrawResource';
import {dropTargetType, TaskDrop} from './task_drop';
import {profile} from '../profiler/decorator';

@profile
export class Tasks { // TODO: update arguments for transfer and similar
export class Tasks {

static attack(target: attackTargetType): TaskAttack {
return new TaskAttack(target);
Expand All @@ -38,10 +36,6 @@ export class Tasks { // TODO: update arguments for transfer and similar
return new TaskClaim(target);
}

// static deposit(target: depositTargetType): TaskDeposit {
// return new TaskDeposit(target);
// }

static dismantle(target: dismantleTargetType): TaskDismantle {
return new TaskDismantle(target);
}
Expand Down

0 comments on commit 4ccb272

Please sign in to comment.