screeps-cartographer icon indicating copy to clipboard operation
screeps-cartographer copied to clipboard

routeCallback failing in `1.8.11`

Open mkaulfers opened this issue 6 months ago • 0 comments

When using the routeCallback(roomName) fails to find an alternative route whenever returning Infinity.

const result = moveTo(this.creep, new RoomPosition(25, 25, nextRoomToScout), {
    maxOps: 200000,
    maxRooms: 64,
    sourceKeeperRoomCost: 10,
    avoidTargets(roomName) {
        const hostileCreeps = Game.rooms[roomName]?.find(FIND_HOSTILE_CREEPS).map(creep => ({ pos: creep.pos, range: 5 })) ?? []
        const hostileStructures = Game.rooms[roomName]?.find(FIND_HOSTILE_STRUCTURES).map(structure => ({ pos: structure.pos, range: 10 })) ?? []
        return hostileCreeps.concat(hostileStructures)
    },
    routeCallback(roomName) {
        const intelData = Memory.intelligenceData
        if (intelData && intelData[roomName]) {
            return intelData.hostile ? Infinity : undefined
        }

        return undefined
    }

Expected:

  • Whenever Infinity is returned from the routeCallback(....) it should avoid that room entirely.

Actual:

  • Providing infinity does not avoid the marked hostile room. Creeps still path through that position.

Dev Notes

  • Using roomCallback(roomName, fromRoom) and providing false seems to be a workaround, however doing so requires that I generate a new Cost Matrix with each planned route which isn't ideal.
  • I have a log [5:12:16 PM]Scout is avoiding W1N1 because it is hostile to verify the integrity of my hostile flag.
  • I was able to reproduce pathing from W2N2 to some position W1N2 with avoidance on W1N1. There is another path that can be taken, and not overly complicated to calculate. I could calculate it normally with default movement & pathfinding. However, to cover all the bases I added in the maxOps and maxRooms.

mkaulfers avatar Sep 03 '24 22:09 mkaulfers