One of the functions I wanted for RF87 was the ability to explore, find other colonists, and trade and interact with them. Given the scale of the distances involved, I came to the conclusion that I would have to change the map scale when dealing with trading, so I would have a separate strategic, or global map.
The global map itself was no problem, however I wanted to make interaction with other colonists as realistic as possible, so set about developing an AI to manage the other colonists. Although there were a lot of tutorial out there on AI for games, they were all focused on creating a combat AI to have enemies pursue and attack the player, so I was on my own. I first mapped out how I wanted the AI controlled colonists to behave, defining what activities they would be like to do, and when, and set up a finite state machine to handle this. The AI colonists will explore the area around them, gather resources, build structures, and cluster together to form villages.
The trickier bit turned out to be how to handle trade. I wanted a realistic trade system where each village specializes in certain kind of goods, would sell what they are good at making, and buy what they are poor at making. The issue was that since the landing spots were random, it meant that the consolidation into villages was also random and there was no guarantee that there would be a village specializing in every type of good. In other words it would be possible that the “planetary economy” produces too much much iron, and not enough ale. Economic theory suggests that the good old “invisible hand” would sort this all out, but since Adam Smith was never kind enough to write out algorithms on how this works in practice, I decided on a simplification rather than spending months developing supply and demand curves for every single type of good in the planetary economy.
Even though this was a simplification, it essentially meant developing my own ERP system for the game. The system I wrote keeps track of production, consumption, inventory levels, and will set up, match, and execute trades. For those of you who just love flowcharts, the trade system is shown here: Trade_Workflow The system works fine, but I don’t think I’ll competing with SAP anytime soon 🙂
This module is complete, and waiting for the rest of the game to be developed. It does function as a self standing game, with some limitations, since a lot of the functionality from the player’s perspective is intended to take place in the player’s local map. However it does give a good indication of what would be expected in the global map from the player’s perspective. The player will explore the new world, find resources, find other villages, can trade with them, if successful may be able to attract villagers to the player’s own colony.