Citybound is a city building game with a focus on realism, collaborative planning and simulation of microscopic details. It is independently developed, open source and funded through Patreon.
The simulation core takes care of the progression and scales of in-game time by frequently updating continuous processes as well as sending one-off notifications and timeouts
Optimal granularity of traffic simulation: simulate the most strongly locally interacting traffic entities (e.g. cars on one lane) all at once within one actor (one lane = one actor)
Cars themselves are not actors, one lane is the atomic actor, it updates all the cars on it in one go
Cars mostly move along a lane like a train, only on switch lanes they can move sideways to merge between normal lanes
Cars react to general obstacles, which are either the next car on their own lane, or cars on interacting lanes, whose position is mapped onto the current lane
Interactions are distinguished as parallel/opposing/merging
Interacting lanes after each update exchange their cars as obstacles for the other lane
Use well-known 1D acceleration and breaking model and extend it to multi-lane behaviour
The complex fabric of real road geometry goes beyond "streets" and "intersections", which at best can be understood as loose groups of related lanes (EMERGENCE, ACTUAL PROBLEM)
All macro-economic behaviours arise from interactions of individual households (families, companies) (emergence)
Members of households have both selfish and shared goals, resulting in a trade-off between individuality and cooperation
Locality of households and interactions is essential and enables all kinds of logistics and distributed industries
All resources that have to physically moved in real life have to also be moved in Citybound
The real estate market is a huge factor in shaping a city
The character of a city is largely determined by the sum of its industries
The vast majority of consumed resources and services depend on complex chains of earlier resources, these resource chains/trees are at the core of shaping industries, the required logistics and thus also a city
The player is not supposed to manage supply/demand/resource chains, but to enable them to be as effective as possible, through the means of infrastructure planning and zoning/governance
Even though the amount of information presented in the game might go way beyond realistically knowable things, this contrast in availability of information compared to the real world has an educational and almost call-to-action aspect to it
Individuals act as a lens to see the game world from, other than the players birds-eye-view
Overall "macro" appearance of the city hints at general issues which might inspire you to investigate in detail
Having to rely on absolute amounts for resources makes balancing very hard and amplifies bugs and makes the system potentially very unstable
The amount of different resource types and how fine-grained they are is to be chosen as minimal as possible, while still producing interesting and prevalent resource chains
Resources represent both tangible goods as well as intangible (psychological, physiological, social) metrics
All of these are measured using scalar values, from -infinity to infinity
these values represent how well a household is doing on a particular resource (0 representing ideal), not necessarily absolute stockpile values
One household and its associated resources are always tied to one specific building/location - if this is one location of a larger company, these cooperate mostly as if they were separate businesses
"Crafting recipes" to determine both how resource combine, at which costs, and which businesses do that
In reality it is not only physically impossible to instantaneously build infrastructure, but there are good reasons why planning is employed before even deciding what to build (planning)
Plans are easy to revise and iterate on, changing existing structure is extremely costly
You can start planning something even when you do not have the permission or resources to implement the plan yet. In fact, you might need to have a plan to show in order to acquire the necessary permission and resources
Planning should be as flexible and forgiving as possible
Instead of keeping a perfect, complicated two-way mapping between plans and implemented reality at all times, they are kept separate
When new structures are added to a plan or previously planned and implemented structures are modified within the plan, they are compared geometrically in detail with the materialized reality to calculate the actual diff of what would change when implementing the new plan
Keep pathfinding information local and dynamically changeable
Make use of the "highway effect" (for most of each trip, only the rough source and rough destination determine the typically important main connections to choose)
Be able to create a trip from household to household (not necessarily precise addresses)
Trips are a persistent representation of each ongoing trip (since cars themselves are not actors, but exist on road actors, or are exchanged as messages)
Trips can be created from and to "rough" locations (such as households), which are then first resolved to precise locations on the road network
Use a simple two-layer landmark model for the pathfinding itself:
"nodes" (individual lanes) and "landmarks" (groups of lanes, represented as one rough destination)
nodes store closest-next-hop information to all landmarks, but only to nodes up to a certain distance
if a node is too far away, first navigate towards its parent landmark, until a direct next-hop is known
lanes organically join/leave landmarks, keeping landmarks continuous each, and of roughly equal group size
lanes exchange information about changed/updated next-hops with their local neighbors (similar to router table updates), forming an eventually converging network
Not only the exchange of physical goods influences the decision-making of families, but intangible psychological, physiological, social metrics play an equally if not more important role
There is no central happiness metric, but only individual diverse motivations that vary both over time as well as from person to person - one can only get a rough overview of "how well someone is doing" by looking at all of them