Skip to content

Repository files navigation

OpenGlassBox

Note: I am also looking for a game developer or an artist able to turn this library into a real game.

OpenGlassBox is a C++14 city-simulation engine inspired by GlassBox, the engine behind Maxis's SimCity (2013). It is a port and extension of Federico D'Angelo's C#/Unity project, MultiAgentSimulation, itself based on the 2012 GDC presentation.

OpenGlassBox is an independent project: neither OpenGlassBox nor MultiAgentSimulation contains Maxis source code or is affiliated with Maxis.

The project provides:

  • static and shared libraries for the simulation engine: they parse rulesets files, let you define gameplay through simple rules, and drive a dynamic city simulation;
  • a standalone, SimCity-like 2D demo built on that engine.

Documentation

Document Contents
Improvements Changes over MultiAgentSimulation.
Installation Compile and install OpenGlassBox.
Engine Classes and tick order.
Traffic Travel times, congestion, and destination search.
Economy What the ruleset does, and what a real economic model would add.
Scripts The .ogs language: the core of the project.
Demo application Tools, panels, and keyboard shortcuts.
Bundled simulations Sample rulesets and the test city walk through.
Integration guide Link the library and drive a simulation from your own code.

Simulation engine and rulesets

The GlassBox approach describes a city simulation as data rather than as a tree of objects with an Update() method. OpenGlassBox models layers, buildings, agents, paths, areas, and the rules that connect them.

  • Areas are zones whose rules spawn, upgrade, and demolish buildings.
  • Maps are 2D grid layers with values, such as water, pollution, desirability ...
  • Units are buildings that hold bounded stocks of resources.
  • Agents carry resources from one unit to another.
  • Resources are money, goods, happiness ...
  • Paths are networks on which agents travel.

Gameplay is defined in rulesets files: resources, building types, agents, maps, zones, and the rules that move resources and grow cities. The C++ engine parse them and executes those rules; therefore, scripts and their parsing are the most important part of the project.

Demo application

The engine library does not depend on the demo renderer, so it can be embedded in another application or connected to a different rendering engine.

This screenshot may not match the current state of the code for the demo application; what you see also depends on the loaded ruleset and city. The demo includes several bundled simulations, from the introductory test_city sandbox to traffic-focused road networks.

OpenGlassBox

One window shows one city. The simulation starts paused: press Play on the map toolbar or the space bar to start it. The Simulation clock panel steps the simulation tick by tick while paused and changes the speed from x0.25 to x16. Opening a ruleset (.ogs) starts from an empty city; a city save (.ogc) holds geometry, live state, and a hash of the ruleset it was built with. The Inspector panel shows details about any selected element; the left toolbar lets you edit the city.

References

About

[Lib][Version 0.2.0][Functional] Sandbox implementation of the simulation engine behind SimCity 5 (GlassBox)

Topics

Resources

Stars

51 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages