Whitepaper of Geopolitical Simulator 5 Gamelogic
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-26 19:49:35 -05:00
_notes Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
entities Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
evidence Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
pseudocode Iter Mon 10/26/2026 16:31:53.52 2026-10-26 16:31:53 -05:00
.gitignore Iter Sun 10/25/2026 21:12:22.49 2026-10-25 21:12:22 -05:00
00_OVERVIEW.md Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
01_SIMULATION_CORE.md Iter Mon 10/26/2026 16:31:53.52 2026-10-26 16:31:53 -05:00
02_ECONOMY.md Iter Mon 10/26/2026 16:31:53.52 2026-10-26 16:31:53 -05:00
03_MILITARY.md Iter Mon 10/26/2026 16:31:53.52 2026-10-26 16:31:53 -05:00
04_POLITICS_AND_POPULARITY.md Iter Mon 10/26/2026 16:31:53.52 2026-10-26 16:31:53 -05:00
05_PERSONALITY_AND_CHARACTERS.md Iter Mon 10/26/2026 17:27:11.50 2026-10-26 17:27:11 -05:00
06_LAWS_AND_LEGISLATION.md Iter Mon 10/26/2026 17:27:11.50 2026-10-26 17:27:11 -05:00
07_DEMOGRAPHY_AND_ENVIRONMENT.md Iter Mon 10/26/2026 16:31:53.52 2026-10-26 16:31:53 -05:00
08_REGIONS_CITIES_AND_INFRASTRUCTURE.md Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
09_AI_AND_SYSTEM_INTERPLAY.md Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
10_GROUPS_AND_COLLECTIVES.md Iter Mon 10/26/2026 19:49:35.06 2026-10-26 19:49:35 -05:00
AUDIT.md iteration 2026-10-25 17:24:46 -05:00
README.md Iter Mon 10/26/2026 14:22:08.00 2026-10-26 14:22:08 -05:00

Geopolitical Simulator 5: Reverse-Engineered Engine Specification

Geopolitical Simulator 5 (Power & Revolution 2026 Edition), application build 1.18. A whitepaper series on the simulation's data structures, update order and arithmetic, reconstructed from the decompiled executable and the shipped data tables, with every claim cited to its source.


What this is, and how to read it

The series describes what the game engine actually computes: where each quantity is stored, which function updates it, in what order, and with what arithmetic. Every statement is tied to the decompiled corpus recomp/full_fns.clean.c (D-001). Where this analysis has not decoded something, the volume records it in its limits section and does not fill the gap with a plausible model.

Each volume states the mechanisms and arithmetic the code implements. Details that remain open are recorded in that volume's limits section. The ledger in evidence/NN_CLAIMS.md records the evidence behind each claim.

Every address-like number in the prose is a bracketed citation with its class:

Form Meaning Example
[fn <rva> <name>] a function header in the corpus [fn 0x215be60 importance_action]
[global <rva> <type>] a global variable [global 0x46208908 ptr] (nation base)
[field <offset> in <RECORD>] a byte offset inside a record [field 0xc4a8 in NATI] (GDP)
[qty <value> <role>] a stride, count or constant [qty 0x645310 stride] (nation record size)
[tag <be-u32> "<FourCC>"] a four-character code used as an immediate [tag 0x4e504942 "NPIB"]
[data <file> "<key>"] a key in a shipped data/gt/*.tsv table [data xan.gt.tsv "211100"] (VAT)

python -I tools/cite.py <hex> resolves any of these. python -I tools/wp_verify.py checks that every prose citation resolves (rules R1/R2, and R7 for the class pages).

Byte offsets. All record offsets in the series are byte offsets. Many engine functions take a short * or float * record pointer, so the decompiler prints scaled indices. The volumes convert them (D-018). The most consequential case is the national-variable dispatcher [fn 0x2593bd0 get_variable], whose printed displacements are half the real byte offsets.


Volume map

flowchart TD
    ROOT["README.md"]
    V00["00 Overview<br/>record pools, variable store"]
    V01["01 Simulation core<br/>clocks, daily driver, stages, turn"]
    V02["02 Economy<br/>sectors, GDP, budget, inflation, FX"]
    V03["03 Military<br/>unit pool, movement, war records"]
    V04["04 Politics<br/>opinion ledger, approval, popularity, unrest"]
    V05["05 Characters<br/>people, profiles, relations, agenda"]
    V06["06 Laws<br/>action rows, votes, dispatch"]
    V07["07 Demography & environment<br/>age pyramid, migration, health, climate"]
    V08["08 Regions<br/>region chain, regional GDP, annexation"]
    V09["09 AI & interplay<br/>AI decisions, the economy-politics loop"]
    V10["10 Groups & collectives<br/>groups, organisations, coalitions"]
    PC["pseudocode/<br/>Python class page per volume"]
    ROOT --> V00
    V00 --> V01
    V01 --> V02
    V01 --> V03
    V01 --> V04
    V04 --> V05
    V04 --> V06
    V02 --> V07
    V02 --> V08
    V02 --> V09
    V04 --> V09
    V06 --> V09
    V04 --> V10
    V06 --> V10
    ROOT --> PC

Volume summaries

Volume 0: Record Pools and the Variable Store

  • What the world is made of. Sixteen anchor record types, each written by a serializer that sets a four-character tag and a fixed record size. Examples:
    • nations: [tag 0x4e415449 "NATI"], [qty 0x645310 stride], 300 slots;
    • people: PERS, [qty 0xad0 stride], 51,000 slots;
    • groups and parties: GROU, [qty 0xb88 stride], 15,000 slots;
    • companies: CORP, [qty 0x1f60 stride], 124,000 slots;
    • action rows: DEFA, [qty 0x3b0 stride];
    • regions: REGI, [qty 0x910 stride].
  • The variable store. A 4,000,000-cell store of 16-byte cells with a free list and a history table. The block length is [qty 0x40d9908 bytes] and the base is [global 0x32d1920 ptr]. Laws and many national variables live here as handles: a nation field holds a cell id, not the value. That is how a law value reaches the economy.
  • The loader. [fn 0x143acd0 Cdatabase__es_base] reads and writes every block.

Volume 1: Simulation Core

  • Clocks. A tick timer and game-hour accumulator produce the day serial [global 0x464916a8 i32]. The macro-turn clock [global 0x50ef4788 f64] advances by (days_in_year / 365) * (1/26) * 365.25 days per turn, about 14.05 days.
  • The daily driver. [fn 0x13f3290 calc_monde] runs one game day in a fixed call order: agenda, actions, units, reactions, the stage frame, the bank rate, the per-nation calc_nation pass, and the end of turn.
  • The stage driver. [fn 0x1409f40 calc_monde_debut_tour_etapes] spreads the start-of-turn work over several frames through 19 labelled stages.
  • The end of turn. [fn 0x140e5d0 calc_monde_fin_tour] runs, in profiler-label order: the AI pass, inflation and currency accumulators, national accounts, the corporate passes, world aggregation with currency and stock-index updates, and the quarterly central-bank step.

Volume 2: Economy

  • Storage. The economy is stored at three levels:
    • per nation: GDP [field 0xc4a8 in NATI], growth CROI [field 0xc594 in NATI], inflation [field 0xc5c0 in NATI], population (a double), the budget totals and the tax handles;
    • per nation and sector: one 16,488-byte account per sector starting at NATI+0xcbc8, holding value added, GDP share, exports, prices and a per-capita level;
    • world-wide: the sector definitions, companies, plants, buildings, the currency table and loans.
  • Commodities. Goods and energy carriers such as EENU and EMPC are sectors keyed by four-letter codes.
  • GDP per turn. [fn 0x1bec6b0 f_1bec6b0] sums the sectors' value added and adds a regional term. It then updates turn growth, trend growth, CROI (a 2% moving average of projected annual growth) and 51 budget lines.
  • Taxes. Rates are read through the action-table handles, so changing the VAT law [data xan.gt.tsv "211100"] changes the handle the tax code reads. The VAT amount is coefficient * base * rate * population ([fn 0x1bf11a0 f_1bf11a0]). The income tax is a real three-tranche blend ([fn 0x1ca3e10 f_1ca3e10]).
  • Inflation. [fn 0x2083fb0 f_2083fb0] takes a weighted average of sector price changes and a piecewise response to growth, then smooths asymmetrically: rises are slower than falls.
  • Money. Currencies move with GDP-weighted accumulators of inflation and interest rates ([fn 0x2083e10 f_2083e10], [fn 0x2083560 f_2083560]). A quarterly central-bank rate steps by 0.0025 toward trend growth ([fn 0x2083a70 f_2083a70]). A separate per-nation bank rate steers toward 0.5 * (inflation - growth) ([fn 0x170fd40 bank_updateInterestRate]).
  • Debt and rates. The annual debt stock is [field 0x6193dc in NATI]; the 103% gate uses DPIB at [field 0xc404 in NATI]. The LOAN table carries the schedule totals.
  • Other parts. The star budgets and the employment rate.

Volume 3: Military

  • Units. One 120,000-slot unit pool ([qty 0x750 stride]) linked per nation. [fn 0x24c5200 calc_unites] moves units and runs their orders each day. Unit-type stats are copied from a type record.
  • Prices. [fn 0x1cba4d0 prix_normal_construction] computes construction prices and [fn 0x24c7870 calcul_cout_reconstruction] reconstruction costs.
  • War. War records are the CONF pool ([qty 0x12d0 stride]). A war score ([fn 0x1329770 f_1329770]) drives percentage effects on nearby population records ([fn 0x219cfb0 gestion_popu_warville]); the daily HP/strength subtraction is Etape17.

Volume 4: Politics and Popularity

  • The opinion ledger. Each nation has a 120-theme ledger: five parallel blocks of tag, weight, target, value and scale, starting at [field 0x620ee0 in NATI]. Eighteen alias pairs map secondary tags onto canonical ones; the five ideological axes are 1DIC, 2LIB, 3CAP, 4SEC and 5IND.
  • Law scoring. [fn 0x215be60 importance_action] turns a law change into an importance in [-4, 4]. [fn 0x215d4a0 f_215d4a0] turns that into a per-theme delta, based on the distance from the people's ideal.
  • Approval. [fn 0x1cd2170 f_1cd2170] sums the ledger with difficulty factors (0.25 / 0.38 / 1.0 / 1.45). It recomputes the budget-driven themes SOLV/SOLB on the spot.
  • Popularity. The head of state's popularity is 0.75 * (0.5 + 0.5 * approval) + 0.25 * (0.5 + peer sum / 2n) plus four stored offsets, held in [-0.1, 1.1] ([fn 0x2190190 f_2190190]). The world value is a population-weighted mean.
  • Unrest. Each trouble stores 1 - approval as its discontent, and the change in discontent feeds its gravity ([fn 0x248bc10 trouble_update_gravite]).

Volume 5: Characters

  • Records. Person records (PERS) hold the role, nation, party, popularity and its offsets. They link to profiles (PEPR, [qty 0x41b8 stride]), which carry the 365-day popularity ring.
  • Behaviour tests and agenda:
    • the corruption test ([fn 0x21c0400 is_perso_corruptible]);
    • the nepotism test;
    • the agenda scheduler ([fn 0x15a5e20 gere_rdv]);
    • the negotiation opening offer ([fn 0x1b98d00 get_nego_start_value]).
  • Private life. Data rows and one scandal flag.
  • Relations. A 300-entry float row per nation at [field 0x61bfb4 in NATI] ([fn 0x897390 f_897390]), and a leader-to-leader affinity built from party positions ([fn 0x21481c0 f_21481c0]).

Volume 6: Laws and Legislation

  • Laws. A law is a 0x3b0-byte action row loaded from xan.gt.tsv. Its value is a variable-store cell, and action_varmap.tsv maps the action to the nation field holding the cell's handle.
  • Effects. [fn 0x1cfb560 calc_effet_loi] applies numeric laws through 30 criterion curves and option-bitmask laws bit by bit.
  • The TGO columns. The five columns name the ideological axes (democracy ↔ dictatorship, and so on).
  • Votes. A seat-weighted tally passes a bill when the share exceeds 0.5. Group support is the weighted mean over the party's members, who are people in the nation's member list, not regions ([fn 0x215bae0 f_215bae0]). A second chamber applies to bicameral nations ([fn 0x2161bf0 parlement_vote_lawpack_chambre2_groupe_from_pres_region]).
  • Dispatch. [fn 0x1d60ce0 traitement_loi] and [fn 0x1d5cc40 traitement_lawpack].
  • The gate. Player laws and AI actions share the legislative-counter gate at [field 0x622274 in NATI].

Volume 7: Demography and Environment

  • Population. A 120-entry age pyramid is recounted into the population double ([fn 0x1c3c060 f_1c3c060]), which the economy uses for taxes and GDP per head. Death and birth rates are calibrated to targets ([fn 0x1c42020 f_1c42020]); the calibrated mortality is applied across the pyramid by [fn 0x1c3c060 f_1c3c060].
  • Migration moves population buckets and the whole pyramid between nations ([fn 0x1c99cf0 f_1c99cf0]).
  • Health. Epidemics are daily stock bookkeeping ([fn 0xd53a40 gestion_epidemies]). Catastrophe victims depend on type and severity ([fn 0x182afc0 calc_cata_victimes_initiales]).
  • Climate. A carbon aggregate with an increase-only overshoot feeds a climate chain that produces temperature, sea level and ocean pH up to 2100.
  • Education indicators are stored variables.

Volume 8: Regions, Cities and Infrastructure

  • The region chain. Regions form a singly linked list from [field 0x2f0 in NATI]. A nation is active exactly when it owns a region ([fn 0x1a47850 nation_is_active]).

  • Regional GDP, two directions:

    • top-down: each region receives national GDP times its coefficient ([fn 0x1c3ef40 f_1c3ef40]);
    • bottom-up term: a separate regional sum enters national GDP each turn ([fn 0x1a253e0 f_1a253e0]).

    The two 365-day moving averages in calc_nation smooth unit-interval indices, not GDP.

  • Territory. Annexation actions rewrite region-to-group references ([fn 0x1992f10 f_1992f10]).

  • Transport pools exist for roads, nodes, bridges and tunnels.

Volume 9: AI Decisions and the Economy-Politics Loop

  • Scheduling. Each computer-run nation's AI runs on three countdowns inside [fn 0x1c366b0 calc_budget_etoile].
  • One AI turn. [fn 0x20c5670 f_20c5670]:
    1. draws an action category with weights driven by the budget deficit and the leader's popularity ([fn 0x20bfb50 f_20bfb50]);
    2. scores candidates as party alignment ×100, plus the public's view scaled by unpopularity, plus a cost term, excluding its last 20 choices ([fn 0x20bb4c0 f_20bb4c0]);
    3. submits the winner ([fn 0x20c5f70 IAContrats__envoyer_action]).
  • Shared machinery. Party and public alignment come from the same importance_action that scores player laws. The validity check reuses the parliament tally ([fn 0x20bcc20 IA_globale__choix_action_valide]).
  • Diplomacy. Treaty acceptance thresholds ([fn 0x20e12a0 f_20e12a0]) and part of the war logic.
  • The loop. Section 5 walks it edge by edge, each edge marked confirmed or not established: law → variable handle → economy → criteria ratings and the SOLV theme → approval → popularity and unrest → AI weights → law.

Volume 10: Groups, Parties and Collectives

  • The pool. GROU is 15,000 records of [qty 0xb88 stride] off [global 0x5d859dc8 i64], serializer [fn 0x146e300].
  • The layout. Twenty-six displacements are anchored; the position [field 0x27c in GROU], the seat bit of [field 0x224 in GROU], the owning nation id [field 0x248 in GROU] and party money [field 0xae8 in GROU] are the ones the other volumes read.
  • Membership. A person points at a group: [field 0x398 in PERS] scaled by the group stride. Membership is read by scanning PERS.
  • Alignment. [fn 0x2148840 alignement_groupe_ideologique] resolves the action row for the group's nation, then returns 1 if the group and the row share one of 30 criterion ids, 0 otherwise.
  • Neighbours. TROU unrest, ORGA organisations and COAL coalitions are separate pools; the volume records their strides, counts, the group-to-coalition link through the nation id, and the coalition lifecycle.

Python class pages

One page per volume restates each record as a @dataclass with byte-offset comments, and each major operation as a class method. Page 09 ends with a FeedbackLoop that calls the other pages' classes in engine order. The pages' evidence footers are checked by rule R7.


Sources and method

flowchart LR
    EXE["game executable (user's install)"] --> DEC["Ghidra decompilation"]
    DEC --> CORPUS["recomp/full_fns.clean.c<br/>125,881 functions"]
    DATA["data/gt/*.gt.tsv<br/>shipped tables"] --> VOL["volumes"]
    CORPUS --> CITE["tools/cite.py resolver"]
    CITE --> VOL
    EMU["emulation checks<br/>tools/orient_check.py, tools/emu_calc_nation.py"] --> VOL
    VOL --> GATE["tools/wp_verify.py gate"]
  1. Corpus of record. recomp/full_fns.clean.c: 125,881 decompiled functions, about 6.6 million lines (D-001). Corpus line numbers in the volumes refer to this file.

  2. Shipped data tables (data/gt/*.gt.tsv, 37 files):

    • xan holds the actions and laws;
    • xim the localized text and opinion labels;
    • xae the sector and ministry rows;
    • xue the unit types;
    • xia the AI candidate catalogue.

    A table value is cited as [data ...], never as a code constant (D-008).

  3. Derived maps such as action_varmap.tsv (action → nation variable handle, built by emulating the mapping function) are leads checked against the corpus, not proof by themselves (D-020).

  4. Emulation. tools/orient_check.py checked the opinion path (importance_action → f_215d4a0) against the original code. The Rust port in gps5-rs/ reproduces the policy → opinion → popularity path on 6,000 emulated cases.

  5. Gate. Run python -I tools/wp_verify.py; add --strict to make the structure, ledger and evidence-index rules gating too.


File index

File Contents
00_OVERVIEW.md Record catalogue, variable store, base pointers.
01_SIMULATION_CORE.md Clocks, calc_monde, stage driver, end-of-turn order, serializer.
02_ECONOMY.md Company/plant/building blocks, sector accounts, GDP, taxes and budget, inflation, currencies, central bank, star budgets, loans.
03_MILITARY.md Unit pool, unit types, construction prices, daily unit pass, war records.
04_POLITICS_AND_POPULARITY.md Opinion ledger, law scoring, approval, popularity equation, unrest.
05_PERSONALITY_AND_CHARACTERS.md Person and profile records, behaviour tests, agenda, negotiation, relations.
06_LAWS_AND_LEGISLATION.md Action rows, option bits, law effects, TGO columns, votes, dispatch.
07_DEMOGRAPHY_AND_ENVIRONMENT.md Age pyramid, rate calibration, migration, epidemics, catastrophes, climate, education.
08_REGIONS_CITIES_AND_INFRASTRUCTURE.md Region chain, regional GDP, annexation, cities, transport.
09_AI_AND_SYSTEM_INTERPLAY.md AI scheduler and scoring, treaties, war AI, the feedback loop.
10_GROUPS_AND_COLLECTIVES.md Group pool and layout, membership link, alignment boolean, money/seats/unrest gates, organisations and coalitions.
entities/ Canonical per-record pages: one markdown and one pseudocode page for each of the 57 record tags, with verified field behaviour and explicit probes.
pseudocode/ Python class pages for Volumes 0-10.
AUDIT.md Citation contract and how to reproduce any verdict.
_notes/ Progress, decode queue, accuracy/defect logs, editor log and preserved editor notes.
evidence/ Per-volume claim ledgers (00_CLAIMS.md … 10_CLAIMS.md) and the resolver classification table.

Part of the GPS5 reverse-engineering effort, for technical analysis and modding interoperability. The game and its data belong to their rights holders; nothing from the game is redistributed here.