In a series of topics I will try to explain some of the systems in SFD you need to be aware of in order to create your own path grid and how the bots operate and what tools you have to help debug your path grid.
Bots in SFD all share the same resources (CPU) so a few design principles are in use to reduce the overall CPU usage from frame to frame:
- Only use ray tracing (in box2D) when required.
- A path grid is used to tell bots how they can navigate the world.
- A shared round-robin system is used for heavy calculations.
- Assumptions are used in certain situations to avoid using ray tracing.
Everything shares the same round-robin system to update heavy calculations. As of now bots use it for various actions and the path grid uses it for dynamic nodes.
Bots use this to figuring out their destination and goal and calculate a path through the path grid. Some calculations are cached for some time before being updated again if possible.
Because of the shared round-robin system and cache times the bots might not do anything at times when there's a lot going on. This can be made clear if spawning a lot of bots that all should navigate to a specific target, they start moving one after another.
Each player instance do have an update routine each frame to comply with all the basic rules of the game. It's also in this update the bot will navigate along any calculated path they have been given or other instructions.
Bots perform actions in the game by pressing virtual keys on a virtual keyboard in their logic. You are also pressing virtual keys on a virtual keyboard, they are just mapped to a physical medium - like a real keyboard or gamepad. Player commands also result in virtual keys being pressed. We have designed it like this to prevent bots from being able to do things you can't, and vice versa. Whatever the bots can do, so can you!
That's a quick overview.