JonathanSafer / screeps

Screeps AI
MIT License
25 stars 7 forks source link

Track spawn pressure via queue #206

Closed JonathanSafer closed 3 months ago

JonathanSafer commented 11 months ago

Use a queue of pairs (game.time, spawntime) to track spawn pressure. A pair would be enqueued whenever spawncreep returns OK. This queue would be stored in Cache. A Tmp variable for current pressure could be used to only calculate this value maximum once per tick. An update would involve pruning (dequeing) all old data off of the front of the queue and then summing all of the spawnTime values.

In the case of a global reset, we should be keeping track of last reset anyway. If last reset was less than 1500 (or whatever the length of the queue is) ticks ago, we multiply pressure by 1500/(Game.time - lastResetTime)

JonathanSafer commented 3 months ago

I actually improved on this by just recording spawntime in creep memory and occasionally summing spawntime of creeps born in the last "lifetime". This was implemented with great success in season 6 and is now on master as well