Idle timer on harvester ticking no work7/31/2023 Saving the CPU that is normally used to see if this creep needs to do anything this tick. This means that I never loop through all the creeps. Processes are passed the creep name instead of the creep knowing which process controls it. Big Improvements Process per action not per creep If a creep is moving to its target and it was going to take 10 ticks to reduce its fatigue to 0 the only CPU used by that creep is the init process checking if some processes have finished and its move process suspend being reduced by 1. It’s a lot more broken up than the old AI but spends a lot of time suspended. No: Create a Move Process and suspend until it completes.No: Suspend for the number of ticks until it would be 0.Is the creep within the given range of the target.No: Create a move process and suspend until it completes.No: Create a Deliver process and suspend until it completes.Yes: Create a Harvest Process and suspend until it completes.Start a harvester lifetime process for it There is a CPU cost to all these comparisons and processing even if it results in do nothing. In the old AI, a harvester creep would get this run every tick: SuspensionĪ big part of my CPU saving in my OS is process suspension. The process will persist in the table until it can be run. This means that some processes might get skipped this tick if there was no CPU to run them. The Kernel can run a process if the current CPU used this tick is below the limit and there is a process to be run. While the Kernel can run a process it runs processes. The next block of my main process is a while statement. It is just sat alone in the process table. This process spawns sub processes for gathering room data and restores the process table from last tick. When creating a new Kernel the process table only has 1 entry which is the Init process. The kernel has all my functions and objects for storing and altering the state of the os during this tick. How does it work?Īt the top of my main loop function, I create a new Kernel. Alongside the Typescript discussion from the last post I have been seeing high praise for Operating Systems for AI Structure. So the solution is a re-write of my AI using another approach. Having more rooms is adding more data to the databases which in turn is increasing the CPU cost of every action in the world. I could make SODB do all that but it’s a fair bit of work that might not return a huge gain. Search refinement isn’t done in a cacheable way and it only caches for the whole search not parts of it. I previously spent a lot of time improving my CPU usage and I’m not sure how my current AI can get any faster. My inbox has been flooded with notifications telling me that my bucket is empty or high CPU forced my script to end etc… which is not good. This is part 19 of my Screeps story, you can read the whole story here.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |