ScreepsQuorum/screeps-quorum

[Bug] Cache needs to be invalidated after a certain point to reevaluate blocked exits

Closed this issue · 4 comments

Exits can be temporarily blocked in the case of Novice zones and other potential obstructions. We need a way to invalidate the cache and reevaluate paths.

if (!opts.ignoreCache) {
const cacheLabel = `route_${Room.serializeName(fromRoom)}_${Room.serializeName(toRoom)}`
const cachedPath = sos.lib.cache.get(cacheLabel)
if (cachedPath) {
return cachedPath
}
const newPath = Game.map.findRoute(fromRoom, toRoom, opts)
const options = { maxttl: 150 }
if (newPath.length >= 4) {
options.persist = true
}
sos.lib.cache.set(cacheLabel, newPath, options)
return newPath
}
}

The cache automatically invalidates after 150 ticks (that's what the maxttl is for).

Interesting, I was running into an issue where my creeps thought an exit was blocked, long after it had been unblocked. I'll dig in a little deeper and see where the true error lies.

You may want to look at the costmatrix generation and caching code, as anything there would trickle up to the pathfinding layer.

Ok, thanks. I'm going to close this issue until I can get a better understanding of where it went wrong.