Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Pathing

Module for pathing-related operations.

Hierarchy

  • Pathing

Index

Methods

Static applyMovingMaximum

  • applyMovingMaximum(matrix: CostMatrix, width: number, height: number): void
  • Transform a CostMatrix such that the cost at each point is transformed to the max of costs in a width x height window (indexed from upper left corner). This requires that terrain be explicitly specified in the matrix!

    Parameters

    • matrix: CostMatrix
    • width: number
    • height: number

    Returns void

Static blockAllCreeps

  • blockAllCreeps(matrix: CostMatrix, room: Room): void
  • Sets all creep positions to impassible

    Parameters

    • matrix: CostMatrix
    • room: Room

    Returns void

Static blockExits

  • blockExits(matrix: CostMatrix, rangeToEdge?: number): void
  • Parameters

    • matrix: CostMatrix
    • Default value rangeToEdge: number = 0

    Returns void

Static blockHostileCreeps

  • blockHostileCreeps(matrix: CostMatrix, room: Room): void
  • Sets hostile creep positions to impassible

    Parameters

    • matrix: CostMatrix
    • room: Room

    Returns void

Static blockImpassibleStructures

  • blockImpassibleStructures(matrix: CostMatrix, room: Room): void
  • Sets impassible structure positions to 0xff

    Parameters

    • matrix: CostMatrix
    • room: Room

    Returns void

Static blockImpassibleTerrain

  • blockImpassibleTerrain(matrix: CostMatrix, roomName: string): void
  • Explicitly blocks off walls for a room

    Parameters

    • matrix: CostMatrix
    • roomName: string

    Returns void

Static calculatePathWeight

  • calculatePathWeight(startPos: RoomPosition, endPos: RoomPosition, options?: MoveOptions): number

Static distance

  • distance(arg1: RoomPosition, arg2: RoomPosition): number
  • Calculate and/or cache the length of the shortest path between two points. Cache is probabilistically cleared in Mem

    Parameters

    • arg1: RoomPosition
    • arg2: RoomPosition

    Returns number

Static findBlockingPos

  • findBlockingPos(startPos: RoomPosition, endPos: RoomPosition, obstacles: (RoomPosition | HasPos)[], options?: MoveOptions): RoomPosition | undefined
  • Like isReachable(), but returns the first position which should be cleared to find a path to destination

    Parameters

    • startPos: RoomPosition
    • endPos: RoomPosition
    • obstacles: (RoomPosition | HasPos)[]
    • Default value options: MoveOptions = {}

    Returns RoomPosition | undefined

Static findFleePath

  • findFleePath(creepPos: RoomPosition, fleeFrom: (RoomPosition | HasPos)[], options?: MoveOptions): PathFinderPath
  • Get a flee path possibly leaving the room; generally called further in advance of kitingPath

    Parameters

    • creepPos: RoomPosition
    • fleeFrom: (RoomPosition | HasPos)[]
    • Default value options: MoveOptions = {}

    Returns PathFinderPath

Static findKitingPath

  • findKitingPath(creepPos: RoomPosition, fleeFrom: (RoomPosition | HasPos)[], options?: MoveOptions): PathFinderPath
  • Get a kiting path within a room

    Parameters

    • creepPos: RoomPosition
    • fleeFrom: (RoomPosition | HasPos)[]
    • Default value options: MoveOptions = {}

    Returns PathFinderPath

Static findPath

  • findPath(origin: RoomPosition, destination: RoomPosition, options?: MoveOptions): PathFinderPath
  • Find a path from origin to destination

    Parameters

    • origin: RoomPosition
    • destination: RoomPosition
    • Default value options: MoveOptions = {}

    Returns PathFinderPath

Static findPathToRoom

  • findPathToRoom(startPos: RoomPosition, roomName: string, options?: MoveOptions): PathFinderPath
  • Returns the shortest path from start to end position, regardless of (passable) terrain

    Parameters

    • startPos: RoomPosition
    • roomName: string
    • Default value options: MoveOptions = {}

    Returns PathFinderPath

Static findPathablePosition

  • findPathablePosition(roomName: string, clearance?: object): RoomPosition
  • Find the first walkable position in the room, spiraling outward from the center

    Parameters

    • roomName: string
    • Default value clearance: object = {width: 1, height: 1}

    Returns RoomPosition

Static findRoute

  • findRoute(origin: string, destination: string, options?: MoveOptions): object | undefined
  • Find a viable sequence of rooms to narrow down Pathfinder algorithm

    Parameters

    • origin: string
    • destination: string
    • Default value options: MoveOptions = {}

    Returns object | undefined

Static findShortestPath

  • findShortestPath(startPos: RoomPosition, endPos: RoomPosition, options?: MoveOptions): PathFinderPath
  • Returns the shortest path from start to end position, regardless of (passable) terrain

    Parameters

    • startPos: RoomPosition
    • endPos: RoomPosition
    • Default value options: MoveOptions = {}

    Returns PathFinderPath

Static findSwarmPath

  • findSwarmPath(origin: RoomPosition, destination: RoomPosition, width: number, height: number, options?: SwarmMoveOptions): PathFinderPath
  • Find a path from origin to destination

    Parameters

    • origin: RoomPosition
    • destination: RoomPosition
    • width: number
    • height: number
    • Default value options: SwarmMoveOptions = {}

    Returns PathFinderPath

Static getCostMatrix

  • getCostMatrix(room: Room, options: MoveOptions, clone?: boolean): CostMatrix
  • Get a cloned copy of the cost matrix for a room with specified options

    Parameters

    • room: Room
    • options: MoveOptions
    • Default value clone: boolean = true

    Returns CostMatrix

Static Private getCostMatrixForInvisibleRoom

  • getCostMatrixForInvisibleRoom(roomName: string, options: MoveOptions, clone?: boolean): CostMatrix | boolean

Static getCreepMatrix

  • getCreepMatrix(room: Room, fromMatrix?: CostMatrix): CostMatrix
  • Avoids creeps in a room

    Parameters

    • room: Room
    • Optional fromMatrix: CostMatrix

    Returns CostMatrix

Static getDefaultMatrix

  • getDefaultMatrix(room: Room): CostMatrix
  • Default matrix for a room, setting impassable structures and constructionSites to impassible

    Parameters

    • room: Room

    Returns CostMatrix

Static getDirectMatrix

  • getDirectMatrix(room: Room): CostMatrix
  • Default matrix for a room, setting impassable structures and constructionSites to impassible, ignoring roads

    Parameters

    • room: Room

    Returns CostMatrix

Static getExitPositions

  • getExitPositions(roomName: string): RoomPosition[]

Static getKitingMatrix

  • getKitingMatrix(room: Room): CostMatrix
  • Kites around hostile creeps in a room

    Parameters

    • room: Room

    Returns CostMatrix

Static getPosWindow

  • getPosWindow(anchor: RoomPosition, width: number, height: number): RoomPosition[]
  • Get a window of offset RoomPositions from an anchor position and a window width and height

    Parameters

    • anchor: RoomPosition
    • width: number
    • height: number

    Returns RoomPosition[]

Static Private getSkMatrix

  • getSkMatrix(room: Room): CostMatrix

Static getSwarmDefaultMatrix

  • getSwarmDefaultMatrix(room: Room, width: number, height: number, options?: SwarmMoveOptions, clone?: boolean): CostMatrix

Static getSwarmTerrainMatrix

  • getSwarmTerrainMatrix(roomName: string, width: number, height: number, exitCost?: number): CostMatrix
  • Get a cloned copy of the cost matrix for a room with specified options

    Parameters

    • roomName: string
    • width: number
    • height: number
    • Default value exitCost: number = 10

    Returns CostMatrix

Static getTerrainMatrix

  • getTerrainMatrix(roomName: string, costs?: TerrainCosts): CostMatrix
  • Get a matrix of explicit terrain values for a room

    Parameters

    • roomName: string
    • Default value costs: TerrainCosts = {plainCost: 1, swampCost: 5}

    Returns CostMatrix

Static isReachable

  • isReachable(startPos: RoomPosition, endPos: RoomPosition, obstacles: (RoomPosition | HasPos)[], options?: MoveOptions): boolean
  • Whether another object in the same room can be reached from the current position

    Parameters

    • startPos: RoomPosition
    • endPos: RoomPosition
    • obstacles: (RoomPosition | HasPos)[]
    • Default value options: MoveOptions = {}

    Returns boolean

Static Private kitingRoomCallback

  • kitingRoomCallback(roomName: string): CostMatrix | boolean

Static nextDirectionInPath

  • nextDirectionInPath(creep: Zerg): number | undefined

Static nextPositionInPath

  • nextPositionInPath(creep: Zerg): RoomPosition | undefined

Static oppositeDirection

  • oppositeDirection(direction: DirectionConstant): DirectionConstant

Static positionAtDirection

  • positionAtDirection(origin: RoomPosition, direction: number): RoomPosition | undefined
  • Returns a position at a direction from origin

    Parameters

    • origin: RoomPosition
    • direction: number

    Returns RoomPosition | undefined

Static preferRamparts

  • preferRamparts(matrix: CostMatrix, room: Room): void
  • Sets walkable rampart positions to 1 if cost is less than 0xfe

    Parameters

    • matrix: CostMatrix
    • room: Room

    Returns void

Static preferRoads

  • preferRoads(matrix: CostMatrix, room: Room): void
  • Sets road positions to 1 if cost is less than 0xfe

    Parameters

    • matrix: CostMatrix
    • room: Room

    Returns void

Static roomCallback

  • roomCallback(roomName: string, origin: RoomPosition, destination: RoomPosition, allowedRooms: object | undefined, options: MoveOptions): CostMatrix | boolean
  • Default room callback, which automatically determines the most appropriate callback method to use

    Parameters

    • roomName: string
    • origin: RoomPosition
    • destination: RoomPosition
    • allowedRooms: object | undefined
    • options: MoveOptions

    Returns CostMatrix | boolean

Static savePath

  • savePath(path: RoomPosition[]): void

Static serializePath

  • serializePath(startPos: RoomPosition, path: RoomPosition[], color?: string): string
  • Serialize a path as a string of move directions

    Parameters

    • startPos: RoomPosition
    • path: RoomPosition[]
    • Default value color: string = "orange"

    Returns string

Static setCostsInRange

  • setCostsInRange(matrix: CostMatrix, pos: RoomPosition | HasPos, range: number, cost?: number, add?: boolean): void
  • Parameters

    • matrix: CostMatrix
    • pos: RoomPosition | HasPos
    • range: number
    • Default value cost: number = 30
    • Default value add: boolean = false

    Returns void

Static setExitCosts

  • setExitCosts(matrix: CostMatrix, roomName: string, cost: number, rangeToEdge?: number): void
  • Parameters

    • matrix: CostMatrix
    • roomName: string
    • cost: number
    • Default value rangeToEdge: number = 0

    Returns void

Static shouldAvoid

  • shouldAvoid(roomName: string): undefined | false | true
  • Check if the room should be avoiding when calculating routes

    Parameters

    • roomName: string

    Returns undefined | false | true

Static swarmRoomCallback

  • swarmRoomCallback(roomName: string, width: number, height: number, options: SwarmMoveOptions): CostMatrix | boolean

Static updateRoomStatus

  • updateRoomStatus(room: Room): void
  • Update memory on whether a room should be avoided based on controller owner

    Parameters

    • room: Room

    Returns void

Static weightedDistance

  • weightedDistance(arg1: RoomPosition, arg2: RoomPosition): number
  • Calculates and/or caches the weighted distance for the most efficient path. Weight is sum of tile weights: Road = 1, Plain = 2, Swamp = 10. Cached weights are cleared in Mem occasionally.

    Parameters

    • arg1: RoomPosition
    • arg2: RoomPosition

    Returns number

Generated using TypeDoc