Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capitalism

An interactive, agent-based economy sandbox drawn as a living force-directed graph.

Overview of a mature mixed economy

Every dot is a person, and every person gets one lifetime. People grow up, found companies, hire each other, earn wages, pay (or evade) taxes, draw welfare, get sick, have children, retire on a state pension, die, and leave their estate to their heirs. Companies compete, expand, go bankrupt, and swallow each other. A government taxes, budgets, provides services, loses approval, collapses, and gets replaced by revolution. You control two policy dials — taxation and regulation — and watch what kind of society falls out of them, from laissez-faire capitalism to full command communism.

There is no engine and no UI framework: a single window, C++17, GLFW, legacy OpenGL, and stb_truetype.


Download

Prebuilt binaries for Windows, macOS (universal), and Linux are attached to every tagged release on the Releases page; every push to main also uploads them as CI artifacts on the Actions tab. For Windows machines without OpenGL drivers (VMs, RDP, basic display adapter), grab the -softgl zip instead — it bundles Mesa's CPU renderer and runs anywhere.

The binaries are not code-signed, so the first launch needs one extra step:

  • Windows — SmartScreen may warn about an unrecognized app: More info → Run anyway. Defender's ML heuristics can also false-positive on new unsigned binaries (reported as Trojan:Win32/...!ml); the executable is built in public by the GitHub Actions workflow straight from this source, so you can restore it from quarantine, or build from source below if you'd rather not trust a downloaded binary. If double-clicking does nothing, check Defender's Protection history first. An OpenGL error dialog instead means the machine has no OpenGL driver — common in VMs, over RDP, or with the basic display adapter, since Windows alone ships none. Install the GPU vendor's driver, enable the VM's 3D acceleration, or copy the x64 opengl32.dll from mesa-dist-win (software rendering, MIT) next to capitalism.exe. If Smart App Control blocks the app ("we can't confirm who wrote it"), there is no per-app override — SAC only runs signed or known apps, including ones you compile yourself. It can be turned off under Settings → Privacy & security → Windows Security → App & browser control, but that is one-way (re-enabling requires reinstalling Windows), so decide deliberately.
  • macOS — the download is quarantined: right-click → Open (once), or xattr -d com.apple.quarantine capitalism.
  • Linuxchmod +x capitalism if needed; requires OpenGL plus an X11 or Wayland session (present on any desktop).

Building from source

All platforms need a C++17 compiler and CMake ≥ 3.16. GLFW is used from the system when installed; otherwise CMake downloads and builds it automatically, so no other dependencies are required on Windows and macOS.

Linux

# Debian/Ubuntu — headers GLFW needs when built from source:
sudo apt install build-essential cmake pkg-config xorg-dev libwayland-dev wayland-protocols libxkbcommon-dev
# Arch: sudo pacman -S base-devel cmake glfw

cmake -S . -B build
cmake --build build -j
./build/capitalism

macOS (Xcode command-line tools + CMake)

cmake -S . -B build
cmake --build build -j
./build/capitalism

Windows (Visual Studio 2019/2022 with C++ workload + CMake)

cmake -S . -B build
cmake --build build --config Release
build\Release\capitalism.exe

Headless mode

./build/capitalism --headless 300 --tax 0.5 --reg 1.0 --pop 120
Flag Meaning Default
--headless [secs] run without a window for N sim-seconds 180
--tax <0..1> initial tax rate 0.30
--reg <0..1> initial regulation level 0.15
--pop <n> initial population 80

Reading the graph

Visual Meaning
Node A person. Founders grow with their company's headcount; the head of government grows with the civil service. Children start tiny and grow into adult size; they hover near their parent.
Node color Company members share their company's hue. Gold = government. Gray = unaffiliated (brighter = wealthier).
Pale ring Founder of the company.
Red ring Failing health (below 40%).
Silver ring Retired.
Cyan ring On welfare.
Gray edges Employment: members feed output to their hub.
Amber edges Corporate taxation: each company's hub pays the government.
Cyan edges Welfare payments (kept nearly invisible unless focused, so they can't drown the graph).
Traveling dots Money in motion — wages stream to hubs, taxes to the state, welfare back out. They freeze when the sim is paused.
Labels Company names fade in as you zoom, Obsidian-style.

Hovering any node highlights its whole cluster and dims the rest of the world; a tooltip shows the person's role, age against their expected lifespan, when they'll retire, wealth, income, tax paid, health, happiness, and skill. Clicking pins the selection so the tooltip follows that person.

Hovering a company: the cluster stays lit, everything else dims


Controls

Mouse

Input Action
Drag empty space (or right/middle drag) Pan, with inertia — flick and release
Scroll Smooth zoom anchored on the cursor
Drag a node Grab a person and fling them; layout springs pull them home
Hover a node Inspect (tooltip + cluster highlight)
Click a node Pin / unpin the selection
Click empty space Clear the selection

The grid is infinite — pan and zoom anywhere; two grid scales fade in and out with zoom.

Keyboard

Key Action
Space Pause / resume the economy (the graph keeps settling while paused)
R Reset the world with the current settings
F Fit the whole graph in view
Tab Hide / show all panels
+ / - Sim speed up / down

Panels

All panels are draggable by their title bars, collapsible via the chevron, and raise on click. Widgets are click-through-proof: a press only counts for the panel it started on.


The panels

Controls — pause/reset; sim speed; population (applied on reset); breeding and idea rates; Tax Rate; Regulation with a live regime label; and the five budget allocation sliders (healthcare, infrastructure, education, welfare, pensions).

Statistics — regime, sim time and fps, population, average age, children and retirees, deaths (old age vs. misery), organisation count, civil servants, unemployment (of the labor force — children and retirees don't count), GDP, average wealth, Gini index, happiness, black-market share, treasury, debt, approval, service quality, the Laffer-optimal tax rate, acquisitions and nationalizations, estates inherited, and revolutions survived.

Laffer Curve — projected tax revenue across all rates. The gold marker is your current rate; the dashed cyan line is the revenue-maximizing rate. Push past the peak and watch revenue fall as effort collapses and evasion explodes.

History — 300-sample sparklines: population, GDP, tax revenue, happiness, unemployment, black market, organisation count, and Gini (inequality).

Organisations — the largest companies by headcount with sector, employees, and funds.


Simulation systems

People

Each person has productivity (0.3–2.5), creativity, health, happiness, wealth, a tax-evasion disposition, an age, and a personal lifespan. Income is earned through work; ~45% of net income is saved and the rest is consumed. Health decays without funded healthcare (and with poverty); education funding slowly raises everyone's productivity, and its absence erodes it. Happiness weighs wealth, employment (or a secure retirement), health, public services, founder status, tax burden, personal freedom, and society-wide inequality.

The life cycle

One sim-second is one year of a life, and every life ends.

  • Childhood — children are born to a parent (with inherited, mutated traits), start as tiny nodes that orbit them, and can't work until 18. A solvent parent pays their upkeep, helped by a child benefit when welfare is funded; orphans fend for themselves.
  • Careers — output ramps up through a worker's twenties, plateaus, and eases off past the mid-fifties. Fertility runs from 18 to 45, so the population has a real pyramid — and a society that fails its young ages itself into decline.
  • Retirement — at the state retirement age (67 under a free market, dropping toward 60 as regulation rises, plus personal variance) people stop working for good: founders hand their company to a successor, civil servants leave the service, and everyone draws whatever pension the Pensions budget slider provides. An underfunded pension leaves retirees burning through savings — elderly poverty is a policy outcome here.
  • Death — mortality is negligible until ~70% of the personal lifespan, then ramps steeply, shaded by health and healthcare funding (good healthcare at birth also adds years). Destitution and government collapse kill at any age. The stats panel counts old age and misery separately, so you always know which kind of society you're running.
  • Inheritance — a positive estate is taxed (0.3 × tax rate + regulation² — full confiscation under communism), then split among the deceased's living children; heirless estates escheat to the state, and debts die with the person. A dead founder's company passes first to a child working in the firm (dynasties are real), else to its wealthiest member. Inheritance visibly concentrates wealth: switching it on raised the measured Gini of the default world by ~0.15.

Companies

Anyone unemployed (or, rarely, an employee ready to quit) with an idea, seed money, and nerve can found a company in one of four sectors — agriculture, industry, services, tech — with sector-specific productivity. Companies pool member output into revenue, pay ~72% out as wages (split by contribution), and retain the rest, with founders drawing a dividend from profit. Solvent companies expand and hire; insolvent ones lay people off (never the founder while others remain) and dissolve when bankrupt or abandoned — fading out visually. When a founder retires or dies, control passes to one of their children working in the firm, else to its wealthiest member. Cash-rich companies acquire smaller rivals: the target's founder is bought out, staff and coffers absorbed.

Government

The government is not an abstraction — it's the gold cluster of actual civil servants, and when it collapses, they scatter. The civil service targets ~6% of the workforce under a free market, rising toward ~92% under full regulation, and can poach from the private sector at full employment. Civil servants run state enterprises: salaried output (immune to tax-rate incentives, taxed like everyone's) whose surplus feeds the treasury.

Spending needs scale with population, the pension rolls, the size of the economy, and regulation. Your five allocation sliders split the budget; how fully the budget is funded determines service effects: healthcare (health regeneration, birth rates, lifespans), infrastructure (productivity multiplier), education (skill growth), welfare (payments to the unemployed, child benefit), pensions (what retirees live on). Persistent surpluses are returned to citizens as a dividend rather than compounding forever.

Approval tracks services, happiness, taxation, and authoritarianism. If approval bottoms out — or debt spirals — the government collapses: services stop, evasion becomes near-total, deaths triple. After 30 seconds a revolution installs a fresh government with a clean balance sheet.

Taxation & the Laffer curve

Work effort falls as the tax rate approaches an unbearable ~90%, and evasion rises with the square of the rate — so actual revenue traces a Laffer curve with an interior optimum (marked live on the panel). Evaded income becomes the black market share of the economy. Taxes below ~20% starve public services instead: health costs land on citizens, skills erode, and GDP quietly sinks — underfunding is a trap on the other side of the curve.

Regulation: 0% free market → 100% communism

The second policy axis. Alongside the slider a regime label tracks where you are:

Range Regime
0–8% Laissez-Faire
8–25% Free Market
25–45% Regulated Market
45–65% Mixed Economy
65–82% Socialist
82–97% Planned Economy
97–100% Communist

Raising regulation simultaneously:

  • Raises barriers to entry — company founding fades out, hitting zero at 100%.
  • Compresses wages from contribution-based toward equal shares, and raises the wage share of revenue (capping founder dividends).
  • Adds compliance drag to private productivity and dampens personal work incentives.
  • Enforces antitrust — acquisitions become rare, impossible at the extreme.
  • Nationalizes: above 65%, the state starts absorbing private companies outright — staff become civil servants, coffers are expropriated.
  • Grows the state: civil-service employment scales toward nearly the whole workforce, paid increasingly flat state wages from state-enterprise output — topped up to subsistence from the treasury when output can't cover it (rations, in effect).
  • Confiscates estates: the inheritance tax rises with regulation², reaching 100% under communism — no private fortunes pass between generations.
  • Lowers the retirement age toward 60 — and inherits the pension bill that comes with it.
  • Breeds a shortage economy — black-market activity climbs steeply past ~55%.
  • Trades freedom for safety: a small happiness bonus from a strong safety net, a growing penalty for lost liberty, and an approval penalty for authoritarianism — though an authoritarian state also suppresses discontent, so approval must sink far lower before the government actually falls.

Full communism: the state has absorbed the economy

Emergent outcomes

Same world, different dials — typical --headless 300 runs (three seeds each):

Mixed economy Communism Austerity Confiscatory tax
Tax / Regulation 30% / 15% 50% / 100% 10% / 15% 95% / 15%
GDP ~21,000/s ~7,000/s ~19,000/s ~3,000/s
Gini (inequality) 0.53 0.37 0.60 0.53
Happiness 68% 43% 60% 40%
Black market 16% 61% 11% 69%
State employment (workforce) 10% 92% 10% 8%
Estates inherited 740 0 490 150
Population (from 80) 447 368 418 180 — or extinct
Notes healthy churn, real M&A private sector abolished, everything confiscated richest and most unequal, misery deaths population collapses to a sliver; one seed in three dies out entirely

Every regime tells on itself through demographics. Communism zeroes out inheritance (the state takes every estate) and posts the lowest Gini — at a third of the mixed economy's output and with two-thirds of activity off the books. Austerity nearly matches the mixed economy's GDP, but the costs land on people instead: the highest inequality of any regime, lower happiness, and the only peacetime destitution deaths. And confiscatory taxation is the Laffer curve taken to its conclusion — incomes evaporate, births stop, and the population falls toward (sometimes past) the edge of extinction.

Zoomed in: labels, founder rings, and money pulses


Architecture

src/
  sim.h / sim.cpp    the entire simulation — no rendering, no GLFW (headless mode uses only this)
  ui.h / ui.cpp      hand-rolled immediate-mode toolkit: panels, sliders, buttons, graphs,
                     rounded shapes, dual-atlas stb_truetype text
  main.cpp           camera, world rendering, interaction, panels, entry point
third_party/
  stb_truetype.h

Layout physics (spatial-hash repulsion, hub springs, wander noise) run on real time, so they stay fluid at any sim speed and keep settling while paused; the economy advances in fixed 0.5s ticks scaled by the speed slider. One sim-second is one year of a person's life.

Continuous integration builds and smoke-tests all three platforms on every push (.github/workflows/build.yml); tagging v* publishes the binaries as a GitHub Release.

Releases

Packages

Contributors

Languages