For those who are following the Pathing Saga, I managed to suss out a solution to my “dead-end” woes by reversing the pathfinding attempt should the first pass yield a dead-end from origin to destination. The reason behind the dead-end situation is that while all gates now connect to at least two sectors, some gates are closer to the destination than those that participate in a more valid route, and because we shut down routes that were determined to be “inefficient”, we can’t backtrack or even move away from the destination in order to get back on track. Reversing the process — calculating from destination to origin — helps solve that in tests because the dead-end sector doesn’t even play a part. Should there be a new dead-end scenario, well…we’ll lie and say there’s no pathing possible.
Now that the route calculation is in a form that I can build upon, I have to re-imagine my NPCs as actual interstellar citizens. If you recall (or don’t want to read back-posts to find out), the current NPC implementation is pretty minimal. A merchant will be instantiated at a random jump gate, ID and fly to a random station in the sector, spend some time there to pretend it’s engaging in Commerce, and will then fly towards a random exit gate and “jump” out of sight. For the player, this looks all above-board, like NPCs are doing similar things to what they’re doing, when in reality the NPC is just aimlessly driving around in tight pattern, appearing and disappearing to make things look like they’re Doing Commerce.
One of the aspects of the game that needs attention is making the commodity market move on it’s own. If the player can ID a static route between two stations which allows him to buy at one and sell at another without having to move around to find better deals, then it’s a failure of purpose. We can avoid this by simulating the moving of goods through “other means”, and one way of doing that is by employing the NPC merchants to actually buy and sell goods to get them out from under the player and alter the stability of trade routes to some degree.
Here’s the framework of a new merchant NPC plan that I roughed out on paper:
The sim of all NPCs will be handled by the NPCController which is currently in charge of setting up NPC pools and spawning the instances in a sector. It currently only runs these processes in the active sector, and doesn’t do anything for any other sectors in the known database. I’ll be adding in the simulation process so that the simulation runs through the data and does what it determines it needs to, checks for the need to instantiate, and handles the instantiation using the current logic in the NPCController for merchant NPCs.
So I guess I need to answer the question “why bother”? This seems like a lot of work for something that the player won’t see, and which could probably be modeled easier by randomly instantiating NPCs here and there, and just redistributing commodities via a background process.
The main goal is to allow players to ID NPCs by name. I want there to be some kind of investment in the universe, and when things become familiar, we tend to feel some kind of kinship or ownership of those familiar elements. Even if there’s no direct interaction with the NPCs, seeing the same named ship may provide impetus for the player to, say, defend the NPC from a pirate attack, whereas with a generic new NPC the player might just pass by…or attack the NPC themselves.
Another reason is because I want there to be a level of logic and realism involving what are the player’s “main competition”. If NPCs could teleport between stations, buying and selling, then they could quickly outstrip the player and potentially unbalance the economics by clearing the shelves or meeting commodity quotas before the player has a chance to reach those stations. Since the player is governed by time and relative distance, this puts the player at a severe disadvantage. Simulating the time it takes for a ship to move across several sectors, dock, buy and sell, and undock gives the player some padding to “get ahead” of NPCs. It also allows the player to follow an NPC. With the instantiation plan, a player should be able to tail a merchant to a gate, jump through, and see that NPC on the other side (with some creative license re: timings). They should be able to follow the NPC to their destination, and then see the NPC leave and start a new route. Would a player do this? Maybe they would, just to see if they could, but they could also decide that they want to scan an NPC that crosses their path, and might decide to engage in piracy of their own. In that case, having cargo matters, and knowing when we should and shouldn’t instantiate a specific NPC in the player’s sector also matters. Going a bit further, if the player could open comms with an NPC, maybe the NPC could offer the player an escort job (if the cargo is worth enough) as an ad hoc mission. None of these could happen in a pleasing manner using the current per-sector instantiation method I have in place right now.