From 901be9984808fafe535f40e51a6f65b755da46ab Mon Sep 17 00:00:00 2001 From: Carson Date: Tue, 28 May 2024 17:02:44 -0700 Subject: [PATCH] sorting by actionCoord if possible --- src/room/creeps/creepMoveProcs.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/room/creeps/creepMoveProcs.ts b/src/room/creeps/creepMoveProcs.ts index 386213bd..218b7bd7 100644 --- a/src/room/creeps/creepMoveProcs.ts +++ b/src/room/creeps/creepMoveProcs.ts @@ -14,7 +14,7 @@ import { import { CustomPathFinderArgs, PathGoal, CustomPathFinder } from 'international/customPathFinder' import { packCoord, packPos, packPosList, unpackCoord, unpackPos, unpackPosAt } from 'other/codec' import { - Utils, + Utils, areCoordsEqual, arePositionsEqual, findAdjacentCoordsToCoord, @@ -423,7 +423,6 @@ export class CreepMoveProcs { const creepInWay = Game.creeps[creepInWayName] || Game.powerCreeps[creepInWayName] if (creepInWay) { - if (creepInWay.moveRequest === packedCoord) { potentialCost += 1 } @@ -509,7 +508,14 @@ export class CreepMoveProcs { // Consider sorting by range to action coord, where closer is more preferred moveOptions.push(...findAdjacentCoordsToCoord(creep.pos)) - Utils.shuffleArray(moveOptions) + + if (creep.actionCoord) { + moveOptions.sort((a, b) => { + return getRange(a, creep.actionCoord) - getRange(b, creep.actionCoord) + }) + } else { + Utils.shuffleArray(moveOptions) + } creep.moveOptions = moveOptions return moveOptions