Skip to content

About

🤴🏼 Clean-room reimplementation of Emperor: Rise of the Middle Kingdom in C++20 and SDL3. Built for modern systems, starting with Apple Silicon macOS. Early development; original game data required.

Topics

Resources

Stars

44 stars

Watchers

8 watching

Forks

Repository files navigation

OpenEmperor

A clean-room reimplementation of Emperor: Rise of the Middle Kingdom for native macOS on Apple Silicon. 0.1.0-alpha.2 includes a playable city sandbox and an optional original-economy experiment. Gameplay and visual parity remain incomplete; original campaigns and savegames are unsupported.

You need your own installed or extracted Emperor game data. Original assets are read directly and are never bundled.

Build and run

Install Xcode Command Line Tools, CMake and OpenSSL 3. CMake fetches pinned SDL3 and JSON dependencies when needed and uses system zlib.

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64
cmake --build build --parallel
./build/openemperor

On first launch, select the Emperor data directory. Play Original economy opens the recommended experimental mode for a new city. Check the data folder, map, difficulty and paid starter or empty start before Start sandbox.

For the current Agriculture human retest, choose 6 Hemp reconfiguration (42), Normal, Cities/Chengdu.map, then P → Empty city. Verify Rule42 / policy3 / schema58, tick0,12000 Funds and no paid buildings, inhabitants or stock. The 30-point handoff keeps human results open and separates the paid starter and earned-save regressions. Its fixed retained executable and actual Main/build/native identity are bound by .local/agri-human-20261203/run-01/final-main-handoff.json, produced after the handoff merge. Verify that receipt before starting; historical Rule41/38 binaries and automated results do not identify or approve this run.

For a first city, choose Cities/Xia.map, Normal and Paid four-house starter, then press Space to run. This explicitly selects the existing Rule18 economy; its measured city still has five House fires. The player guide covers production, development, saving and the remaining limits.

P Playable Agriculture starts the separate authored farming mode: Wheat, Millet, Rice, Cabbage and Soy-to-BeanCurd feed the existing Market/House supply. Each paid Farm supports one productive field; Rice needs fertility100 ground. This mode also includes the existing plantations and irrigation infrastructure. See the agriculture guide.

F Playable Fishing starts the separate successor with Fish production: a paid shore Quay launches real boats to finite fishing areas, returns and unloads Fish, then supplies Markets and Houses through physical deliveries. It also retains the five crops, plantations and irrigation. See the fishing guide.

Y Playable Hunting adds paid Hunter's Tents, living wildlife and Meat. Hunters pursue actual animals and carry Meat back before Markets and Houses can receive and consume it. This authored mode retains all crops and fishing. See the hunting guide.

C Multi-field Agriculture shares each Farm's finite labor across up to eight paid fields. Every field retains its own crop progress and harvest history; additional fields share the Farm's work rather than adding free throughput. Select a Farm or one of its fields to bind another field to that Farm. The mode retains hunting, fishing, plantations and irrigation. See the multi-field guide.

E Physical Growers sends a Farm worker to tend each selected crop, carry its harvest back and credit Food only after the real Farm return. The worker shares the Farm's existing staff and finite storage. Working and returning Growers use an explicitly authored marker; their inspector shows crop and cargo.

Z Seasons selects the separate Rule32 seasonal successor. The existing World calendar gates all five Food crops, Hemp, Tea, Lacquer and Mulberry; each plant's inspector shows its numeric season windows, next opening and any pending expiry. Food needs real field harvest work and Farm return, and Hemp needs real pickup and return. Plan stored reserves and year-round fishing/hunting for scarcity. These schedules and yields are authored; older modes keep their existing clocks. See the seasonal guide.

X Irrigation yields or --irrigation-productivity selects separate Rule33. An actually supplied, eligible crop earns one extra growth unit per four real wet work ticks. Inspect a field or plant for its Pump, wet/dry state, retained carry and current work blocker. Harvesting and physical return still credit stock.

Q Food processing or --food-processing selects separate Rule34. Build a Mill (Shift-M), then a FoodShop (Shift-K) beside a paid Market. Select the Mill and use Recipe grade / Shift-G to choose one to four distinct ingredients. Actual staffed work turns each consumed ingredient portion into one Dinners portion of that grade. Physical shop deliveries share the existing House Food stock and consumption event. Inspect recipes, cargo, returns and first receipts. These recipes and timing are authored; Salt, Spices and grade5 remain unavailable in Rules34–39. Their separate Rule40 selection is described below.

V Food Warehouses or --food-warehouses selects separate Rule35. Existing paid Warehouses gain a finite Food compartment and their own Food courier. Raw Food travels to Mills or Markets; stored Dinners travel to FoodShops. Inspect the Warehouse for typed stock, capacity, cargo and actual receipts. Goods/Aux storage and older modes retain their existing contracts.

R Reconfigure or --agriculture-reconfiguration selects Rule36. Drain and remove settled paid Food fields, plantation plants and Pumps, then rebuild at full cost with new identities. Real work, cargo and histories remain conserved; Farmhouses, Quays, Tents, processors and stock owners remain protected. See the reconfiguration guide. This mode also shows actual field/plant stages, work and water overlays, and physical workers, boats and wildlife. Qualified Original art and labelled authored geometry are distinguished in the visual guide.

J Irrigated harvest (37) or --irrigated-harvest selects the separate Rule37/policy3/schema53 successor to Rule36. Harvest admission uses actual field work and earned wet-growth bonuses, so an irrigated crop can finish growth before eighty elapsed field ticks. Five real harvest-work ticks and the physical Farm return remain required. Neutral Well placement also rejects footprints occupied by live actors or their begun edges. Prices, staffing, limits and older saves retain their existing contracts. See the irrigated-harvest guide.

8 Quality-aware Food (38) or --quality-aware-food-dispatch selects the separate Rule38/policy3/schema54 successor. It inherits Rule37's earned harvest and safe Well placement. Markets consider an occupied House's current source-model FoodQuality requirement when loading physical raw Food. An already qualifying mixed load stays unchanged; otherwise a qualifying subset of up to four available portions or another eligible House is chosen. Delivery still takes the real route; a higher House requirement earned during travel is not predicted. Prices, storage, staffing, timing and82/58 budgets remain unchanged. J37 and all older modes retain their own rules and saves; Rule18 remains recommended play. See the versioned architecture.

9 Complete reconfiguration (39) or --complete-agriculture-reconfiguration selects the separate Rule39/schema55 successor. Settled empty Farms, plantation sheds, Quays, Hunter's Tents, Mills, FoodShops and Food Warehouses can now be removed through the existing confirmed paid command. Drain their actual work, cargo, deliveries and eligible stock first; retire child Fields/plants before their source. A stocked Mill must process uncommitted raw ingredients before Drain. Removal gives no refund; rebuilds pay full price and receive new identities. The eight-entry lifetime journal, 82-body/58-channel budgets and per-kind quotas remain finite. See the complete reconfiguration guide.

0 Salt / Spices / Grade5 (40) or --salt-spices-grade5 selects the separate Rule40/policy3/schema56 successor. Earn Salt through a paid, finite authored Mine and order prepaid Spices through a source-bound physical Caravan. Only actual arrivals supply the Mill's separate supplements; its two Grade5 recipes then require staffed work and real Mill→Shop→House delivery and consumption. Rules, controls and limits, executed checks.

7 Food logistics (41) or --advanced-food-logistics adds explicit physical Warehouse relays, direct Warehouse→House supply and FoodShop→Market→House meals of all five grades. Ctrl-W/Ctrl-K select an owner; Shift-L changes its future routing (Ctrl-Shift-L cycles backward). Existing stock, capacity, FoodQuality, physical movement and the sole Food event remain authoritative. See the route controls and limits. The technical checks separate paid logistics evidence, real Funds/staffing limitations and outstanding human acceptance; the complete Agriculture status matrix is in the contract.

6 Hemp reconfiguration (42) or --hemp-reconfiguration selects the separate Rule42/policy3/schema58 successor. It inherits the Food, processing, logistics and presentation controls above. Select a Hemp Field, choose Drain, let earned growth/pickup and the real Grower return settle, then confirm Demolish. Drain/remove live children before their Hemp Farm; retained source stock must leave through normal Goods deliveries before source removal. The removal footer distinguishes unsupported types from temporary obligations; wheel over its details and click Inspect blocker to select and centre an actual visiting or returning courier. An empty Fire Inspector remains a service visit until its physical return. Existing 9 and 7 still select39 and41. There is no migration, refund, stock discard or recycled identity. Two lifetime Hemp Farm and two lifetime Field purchases, eight reconfiguration rows and the 82-body/58-channel bounds remain. See the Hemp reconfiguration contract.

Rule42 also shows the current fire warning above the map. T opens the contextual start plan and actual staffing, Funds and installed upkeep. Begin with four connected Houses, a staffed Well and Ancestor Shrine; buy and connect two Fire Watches early, then one Food Farm with Wheat and a Market. Wait for actual immigration and source staffing before adding optional jobs. Ctrl-O selects the Food Farm; F selects Fire Watch construction. A paused producer still faces fire risk and pays installed upkeep. The building/House/Watch Inspector separates actual protection from an incoming Inspector and offers Inspect Watch / target / Inspector links. An ETA describes an existing usable physical path in simulation ticks; it promises no protection or future visit. Two Watches are finite physical services, not universal fire coverage.

In Rule41 the build toolbar has four groups and ten tools per page. < tools / tools > changes page. Group changes keep the map, Inspector and bottom Select / Pause / Step / 1× / 2× / 4× / Save / Load row in place; Help remains at the top. Map zoom does not scale UI text. Each build card shows its real price and relevant quota. Click a gray action for its current prerequisite; the active-tool area shows the parent context and actual placement reason. Wheel over that area to read a long explanation. Pause work, Drain and Demolish / No removal are separate controls and states.

Group and visible pages Tools Existing keys
City / services, 1–2 Roads/removal, Common/Elite housing, Water/Influence Wells, Watch, Herbalist, Acupuncture, shrines, Academy, three schools, desirability and terrain-link controls Road1, Remove6, House7; Q/I Wells; F Watch; J Herbalist;9 Acupuncture; Y/U/K shrines; V Academy; E/C/A schools; D desirability; B/P terrain links when supported
Agriculture, 1–2 Food Farm, five crops, Hemp Farm/Field, Ditch/Pump, rotation/removal/water view, Fishing Quay, Hunter's Tent O Farm; W/L Wheat/Millet; Shift-R/C/S Rice/Cabbage/Soy; N/M Hemp; Shift-D/P/X/V water tools; Shift-F Quay; R rotates active Pump/Quay; Shift-H Tent
Food / logistics Market, Warehouse, Mill, Food Shop, recipe, gateway/Spices and forward/backward Food routes 0/4 Market/Store; Shift-M/K/G Mill/Shop/recipe; Ctrl-M/W/K selects owners; Shift-B/I gateway/Spices; Shift-L / Ctrl-Shift-L routes
Materials, 1–2 Clay, Pottery, Logging, Smelter, Bronzeware, Lacquerware, Paper Maker, Weaver, Tea Shed/Tea Bush, Refinery/Lacquer Tree, Silkworm/Mulberry, Salt Mine 2/3 Clay/Pottery; Shift-J Salt Mine; Ctrl-J selects a Mine; all twelve industry/plantation tools have normal mouse access

Terrain links and camera Reset remain unavailable where the selected contract does not support them; their gray controls explain this. Keys1–9 retain their existing construction meanings, not speed selection. Space, ., +/-, F5/F9, H/? and Tab retain pause, step, speed, save/load, Help and Inspector controls respectively. Rule40 and earlier retain their existing toolbar layout and exact gameplay/save contracts.

Rule41's normal production Inspector starts with operation, actual assigned / required workers, city workforce, stock, activity and the next step. It lists the primary blocker and other active conditions rather than treating an open season as proof of staffing. Ctrl-O cycles paid Food Farms and Ctrl-N cycles paid Hemp Farms; these select existing owners without buying. Click a Farm's compact Field #… > crop row to inspect its real field. Field growth, five harvest-work ticks, loaded return and credited source stock are separate. Numbered calendar sections and time to the next window use simulation ticks. All twelve raw/graded-meal columns retain their actual stock, incoming and reserved-return values. F1 opens the retained technical/model/callback and reconfiguration details. Goods couriers are named from actual loaded goods; an empty channel keeps a neutral Goods title.

Select a Mill to click Set grade 1–5 directly. The Inspector separates the future recipe from an already committed batch, lists actual distinct raw ingredients and shows Salt/Spices stock separately. Choosing a grade creates no ingredients or meals. Select a Market before the Food Shop tool to see its eight cardinal origin positions; blue outlines describe geometry, while the current candidate uses the complete paid placement check and names its actual parent. A changed parent at mouse release requires a fresh click.

Mill controls bind a named boundary Warehouse for 40 Funds, then order two Spices for 12 prepaid Funds. The city shares eight finite orders / sixteen Spices, rather than a new offer for each Mill. Outward payment, loaded Caravan cargo and accepted Mill stock are distinct. Salt has two lifetime Mine purchases, each with a separate sixteen-portion deposit and storage eight. Exhaustion does not replenish either resource. These finite limits remain a separate long-term gameplay decision.

Warehouse and Food Shop Inspectors offer specific Future route choices, including a named Warehouse relay or the Shop's permanent parent Market. The existing loaded trip keeps its actual target, cargo and return reservation; the new choice applies to later departures. Materials pages expose the existing chains: Tea Shed/Bush → Tea, Refinery/Tree → Lacquer, Silkworm/Mulberry → Raw Silk → Weaver/Silk, and Logging/Wood + Lacquer → Lacquerware. Tool access alone proves no later House luxury consumption.

Rule41 gives Hunters Tent, Salt Mine, Mill and Food Shop distinct own procedural bodies, matching translucent placement previews and visible-pixel selection. Their paid footprints and depth anchors stay unchanged. Normal labels use the building names; F1 identifies the authored geometry and still-unqualified Original artwork. Actual work, pause, fire and available Drain state remain World observations. Earlier modes retain their historical drawings.

Select a visible Agriculture actor for its actual owner, task, cargo and prepared route. Rule41 includes distinct Salt couriers and Spices caravans; the normal Inspector separates the current leg destination from a retained delivery/gateway target. An accepted empty Salt return remains a live trip until source settlement. Own transport poses use actual movement counters; F1 retains provenance and history. Original animation registration remains unqualified where documented; no new sprite IDs or ambient clock are added.

For Rule41 Field/plant tools, selecting a paid Farm/source or its actual child sets an Explicit parent for that family. It survives repeated purchases, refusals, tool changes, Escape and camera movement. Cycle parent selects an existing matching source; Auto / clear (or Ctrl-Backspace) removes the binding. Hemp still requires an explicit paid Farm. Automatic Food selection keeps the existing nearest available Farm and canonical ties; selecting the new Field after purchase does not silently bind later purchases to it. Each material species has its own context. Loading a World clears these temporary UI choices.

The blue work-area outline describes geometry, including occupied cells; only the current candidate's full World check decides green/red. Wheel over tool details for the actual chosen parent, active versus lifetime children, lifetime body/channel limits, price and available Funds. Rice requires immutable source fertility100; a Pump cannot bypass it and a dry valid site remains legal. A changed parent choice or interrupted placement gesture requires a fresh click.

For Rule41 Pump / Shift-P and Quay / Shift-F, R cycles the displayed physical orientation0–3. The prepared preview labels B body, W water, L land, D exterior dock and S outflow seed. ! marks a failed local condition, ? an unevaluated condition, and + completed local checks. Wheel over tool details for the exact failed cell and reason; F1 adds raw source facts. A local pass does not replace the complete placement/payment check. Pump seeds are neutral outlets for paid Ditches; its six external intake cells are water context. The Quay's dock is a fifth exclusive occupied cell. An eligible Pump fills connected paid Ditches on the water update; Fish becomes stock only after actual boat return and dock unload.

For a reproducible empty Agriculture city, use the normal menu rather than the direct sandbox command. Build the current checkout as above, then launch that file with your own data and a new private session path:

mkdir -p .local/agri-human-start
mkdir .local/agri-human-start/run-01 &&
./build/openemperor --data "$PWD/.local/gog-extracted/app" \
  --app-root "$PWD/.local/agri-human-start/run-01"

If the session already exists, choose a new suffix. Select 6 Hemp reconfiguration (42), Normal, Cities/Chengdu.map and press P until Empty city is shown. Check the pre-start map, Rule42/policy3/schema58 and start type, then press Enter. Empty starts at tick0 with12000 Funds and no paid city buildings, inhabitants or goods; map scenery/wildlife is separate. Paid four-house starter instead makes real purchases. The existing direct --sandbox ... --hemp-reconfiguration fresh start selects that paid starter; it is not an empty-city shortcut. 7 Food logistics (41) remains the separate historical Rule41/schema57 selection. --app-root is menu-only, and no --empty flag exists. See the current human-start steps for the fixed retained-binary path, its external final-main verification receipt and separate Empty/owned-save sessions. Root creates that final Main build and native receipt after the handoff merge; no final Prompt11 native PASS is implied.

The current human playtest checklist preserves all30 results as NOT_RUN. Prompt11 technical checks record the maintained Alpha's561/561 PASS in each of Debug, Release and ASan/UBSan, independent core74×3, historical comparisons and the complete Creator/Replay artifact audit. The outer Alpha02 runner's compile-database ordering failure remains FAIL; a separate read-only provenance closeout proves the unchanged complete compiler records and binaries. The mixed Rule42 city earns Raw7, grades1–5 and actual luxury use, followed by20400 observed ticks; its deficits, devolutions and−14011 final Funds are documented without a sustainability claim. Automated native mouse remains NOT_VERIFIED.

HISTORICAL — Rule38/MAC14: Frozen final05 passes451/451 tests in each of Debug, Release and ASan/UBSan, independent core74×3, historical-save comparisons and the scoped100000-tick QA-observer/RSS check. The paid Rule38 city earns all14 whole-city criteria through120000 ticks and ten post-maturity years, with independent replay in all three configurations.

Native05 verifies Cocoa/Metal startup, menu8, loaded-cargo F5/F9, pan, zoom and Help, using a diagnostic bundle with fallback art. The resource-complete Native06 check passes with the same Release binary: qualified Original House/building/road art at1×/2×/4×, pan/resize and byte-exact loaded-cargo F5/F9. Its final preservation guards pass; Original files stay external and read-only. Tent/Mill and unqualified workers retain authored fallback. Automated mouse and600×400 checks remain NOT_VERIFIED, and all human acceptance remains NOT_RUN. These scoped checks add no Original-runtime parity claim; earlier generations retain their own contracts and evidence.

Advanced / Legacy → N New Sandbox retains the classic sandbox profiles and their defaults; O/F/S/M/W/I/D/T/U retain the individual economy experiments. L Load Save continues an existing OpenEmperor save with its own rules. Saving or loading never upgrades an original-economy generation.

Controls

  • Space pauses or resumes; . advances one paused tick.
  • Arrow keys pan; the mouse wheel zooms; Z cycles 1×/2×/4×.
  • F5 / F9 save and load; Escape returns to the menu.
  • Help lists the current profile's tools and shortcuts.

Saves and settings normally live in ~/Library/Application Support/OpenEmperor/OpenEmperor/ on macOS.

See known issues for current limitations and documentation for gameplay, development, testing and packaging.

About

🤴🏼 Clean-room reimplementation of Emperor: Rise of the Middle Kingdom in C++20 and SDL3. Built for modern systems, starting with Apple Silicon macOS. Early development; original game data required.

Topics

Resources

Stars

44 stars

Watchers

8 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages