screeps-cartographer
screeps-cartographer copied to clipboard
routeCallback failing in `1.8.11`
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 therouteCallback(....)
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 providingfalse
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 positionW1N2
with avoidance onW1N1
. 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 themaxOps
andmaxRooms
.