'Screeps Basic OS Functionality
So I'm fairly new to Screeps, and I've been iterating over several design decisions for my bot. Some back-story is that I've tried using a decision tree which worked, until it got messy. I then considered a FSM (Finite State Machine), which then led to a HFSM (Hierarchical Finite State Machine), and then someone suggested an OS. I started doing some research on the topic and the only thing that I can truly figure out is the different required items to successfully implement an OS. What is the basic structure of a Screeps OS?
Kernel
- My understanding is that the "Kernel" tracks CPU usage for processes and also tracks how many ticks it might require to run a given process. It provides this data for the task Scheduler, which then places processes into a Queue. How do I track the process from the kernel, is there a callback syntax for a process? I've looked into doing some math such as
Game.getCPU - Game.getUsedCpuand mixing it withGame.timeto calculate how much effort it takes to actually run the process, but I don't know how to get that data back to the Kernel without just throwing it in memory, which works, but seems like unnecessary overhead.
Task Scheduler
- This one seems the simplest to accomplish, simply build a Stack/Queue for the processes, but what's the syntax here? Do I just create a stack that has a
runprocess in it, then augment with a function that adds new items to the queue? How should I properly decide to add items to the queue? I can arbitrarily add a priority to items, but I feel like there is a better way to handle it.
Process
- This part is hands-down the easiest portion of the OS, just create a Run function for a given process, but somehow I have to make that available to the task scheduler as well as make the kernel aware of it's existence. Furthermore, with this process, should I use a state-machine for each process or should it be abstracted out even further into sub-processes which are also handled by the kernel?
I've also looked at Public OS's from other players but even the basic ones seem like a different language to me because I don't understand the context fully. Is there any resource you can add, perhaps not even screeps related, that might help?
This is the only real "Resource" I've been able to locate, and it's sparse at best. https://wiki.screepspl.us/index.php/Operating_System
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
