You are currently viewing Work in progress 2021/10: NPC ships again! πŸ‘¨β€πŸ”§

Work in progress 2021/10: NPC ships again! πŸ‘¨β€πŸ”§

The intent is the same as presented in the previous post, that is to make the NPCs persistent and flying around the galaxy even when out of sight of the player. However the initial implementation attempt was too focused on generating “traffic” and not flexible enough.

The problem was revealed when starting to deal with the roughly 1% of flight planning failures (even when following pre-established routes the planner may fail to find a detailed path sometimes). Built primarily as a sequencer the model was definitely not suited to handle disruptions, and obviously that did not bode well thinking about managing mission goals or interacting with the player.

So after doing my homework on the issue the NPCs are now being fitted with a proper “hierarchical behavioral model”. That is roughly a system with decision making layers at the top that govern underlying execution tasks, and importantly which should be open for future extensions. Regarding the current objective the galactic traffic should then naturally result from the NPCs’ activity, it’s not a goal in itself actually.

At the moment the new model can manage far away ships (as before) but with the added capability to cope with flight planning failures and galactic routing without a pre-computed schedule in general. I’m now working on the execution tasks and modules for nearby ships, starting with their comms so they can interface with OTC (traffic control) through the game’s regular radio layer.

On the technical side the model is now advanced enough to measure the computing workload related to NPCs. That work is quite heavy and therefore done in the background. The good news is that CPUs with 8 threads or more (typ 4 cores + Hyper-threading / SMT) should do the job, including at large time acceleration.
Also after some fixes and optimizations the sim remains “smooth” with nominal FPS and no stuttering.
(The post’s image is a view of a 12-thread CPU’s activity during peak NPC flight planning load, with core affinity turned on. The top 6 slots are reserved for the fast concurrent tasks, audio and main execution thread, and the bottom ones handle the heavy flight planning jobs)

This time the next update should have on-screen NPCs flying, thanks for reading!

Leave a Reply