Interface MoveOpts

Hierarchy

Properties

avoidCreeps?: boolean

Automatically populates cost matrix with creep positions.

avoidObstacleStructures?: boolean

Automatically populates cost matrix with structure positions.

avoidPortals?: boolean

By default, portals are used for travel if they are the shortest path. Set this to true to avoid using portals for travel.

avoidSourceKeepers?: boolean

Always path around Source Keeper-protected resources.

avoidTargetGradient?: number

Gradient for avoid targets - by default, tiles within an avoidTarget will be set to 254, but if a gradient is set, the cost will decrease by (gradient * range) for each tile away from the target.

avoidTargets?: ((roomName: string) => MoveTarget[])

Type declaration

    • (roomName: string): MoveTarget[]
    • Targets for dynamic avoidance - will re-route to path around avoidance regions if they intersect with creep's current path

      Parameters

      • roomName: string

      Returns MoveTarget[]

Caching strategy to use to save paths. Defaults to HeapCache.

creepMovementInfo?: {
    body: ({
        boost?: "ZO" | "ZHO2" | "XZHO2";
        hits: number;
        type: "move";
    } | {
        boost?: "UO" | "LH" | "ZH" | "GH" | "UHO2" | "LH2O" | "ZH2O" | "GH2O" | "XUHO2" | "XLH2O" | "XZH2O" | "XGH2O";
        hits: number;
        type: "work";
    } | {
        boost?: "KH" | "KH2O" | "XKH2O";
        hits: number;
        type: "carry";
    } | {
        boost?: "UH" | "UH2O" | "XUH2O";
        hits: number;
        type: "attack";
    } | {
        boost?: "KO" | "KHO2" | "XKHO2";
        hits: number;
        type: "ranged_attack";
    } | {
        boost?: "GO" | "GHO2" | "XGHO2";
        hits: number;
        type: "tough";
    } | {
        boost?: "LO" | "LHO2" | "XLHO2";
        hits: number;
        type: "heal";
    } | {
        boost?: string | number;
        hits: number;
        type: "claim";
    })[];
    usedCapacity: number;
}

Creep used capacity and body, used to calculate default terrain costs.

Type declaration

  • body: ({
        boost?: "ZO" | "ZHO2" | "XZHO2";
        hits: number;
        type: "move";
    } | {
        boost?: "UO" | "LH" | "ZH" | "GH" | "UHO2" | "LH2O" | "ZH2O" | "GH2O" | "XUHO2" | "XLH2O" | "XZH2O" | "XGH2O";
        hits: number;
        type: "work";
    } | {
        boost?: "KH" | "KH2O" | "XKH2O";
        hits: number;
        type: "carry";
    } | {
        boost?: "UH" | "UH2O" | "XUH2O";
        hits: number;
        type: "attack";
    } | {
        boost?: "KO" | "KHO2" | "XKHO2";
        hits: number;
        type: "ranged_attack";
    } | {
        boost?: "GO" | "GHO2" | "XGHO2";
        hits: number;
        type: "tough";
    } | {
        boost?: "LO" | "LHO2" | "XLHO2";
        hits: number;
        type: "heal";
    } | {
        boost?: string | number;
        hits: number;
        type: "claim";
    })[]
  • usedCapacity: number
defaultRoomCost?: number

Default cost for a room in findRoute callback (may be overridden if routeCallback is provided). Defaults to 2.

flee?: boolean

Instead of searching for a path to the goals this will search for a path away from the goals. The cheapest path that is out of range of every goal will be returned. The default is false.

heuristicWeight?: number

Weight to apply to the heuristic in the A* formula F = G + weight * H. Use this option only if you understand the underlying A* algorithm mechanics! The default value is 1.

highwayRoomCost?: number

Cost for a highway room in findRoute callback (may be overridden if routeCallback is provided). Defaults to 1.

ignorePortals?: boolean

By default, portals will be blocked in the cost matrix if we aren't traveling through them to avoid ending up somewhere random. Set this to true to ignore portals in the cost matrix. This does not affect travel through portals.

keepTargetInRoom?: boolean

If target range would extend out of the target room, trim to keep target in room

maxCost?: number

The maximum allowed cost of the path returned. If at any point the pathfinder detects that it is impossible to find a path with a cost less than or equal to maxCost it will immediately halt the search. The default is Infinity.

maxOps?: number

The maximum allowed pathfinding operations. You can limit CPU time used for the search based on ratio 1 op ~ 0.001 CPU. The default value is 2000.

maxOpsPerRoom?: number

The maximum allowed pathfinding operations per room (if maxOps is higher for a short path, PathFinder will use the lower). You can limit CPU time used for the search based on ratio 1 op ~ 0.001 CPU. The default value is 2000.

maxRooms?: number

The maximum allowed rooms to search. The default (and maximum) is 16.

plainCost?: number

Cost for walking on plain positions. The default is 2.

priority?: number

Movement priority (higher-value moves override lower-value moves). The default is 1.

repathIfStuck?: number

Number of ticks to wait for a creep to become unstuck before repathing with the fallbackOpts. Default is 3.

reusePath?: number

Number of ticks to save a cached path before repathing. If undefined, cached path will be reused indefinitely. Default is undefined.

roadCost?: number

Cost for walking on road positions. The default is 1.

routeCallback?: ((roomName: string, fromRoomName: string) => undefined | number)

Type declaration

    • (roomName: string, fromRoomName: string): undefined | number
    • This callback works like the builtin findRoute and will override the default values for highway/source keeper room cost unless you return undefined.

      Parameters

      • roomName: string
      • fromRoomName: string

      Returns undefined | number

sourceKeeperRoomCost?: number

Cost for a Source Keeper room in findRoute callback (may be overridden if routeCallback is provided). Defaults to 2.

swampCost?: number

Cost for walking on swamp positions. The default is 10.

visualizePathStyle?: PolyStyle

If set, will visualize the path using provided styles.

Methods

  • Request from the pathfinder to generate a CostMatrix for a certain room. The callback accepts one argument, roomName. This callback will only be called once per room per search. If you are running multiple pathfinding operations in a single room and in a single tick you may consider caching your CostMatrix to speed up your code. Please read the CostMatrix documentation below for more information on CostMatrix.

    Parameters

    • roomName: string

      The name of the room the pathfinder needs a cost matrix for.

    Returns boolean | CostMatrix

Generated using TypeDoc