Settlements no longer prosper on local food alone. A derived economic layer:
trade routes link nearby settlements, prosperity accrues at hubs, and prosperity
boosts population growth. Like territory/culture it's a pure function of the
(saved) settlements + geography + wars/diplomacy -- recomputed each sim year,
NO new saved state and NO save-version bump.
- PlanetTrade.{hpp,cpp}: computeTrade() builds TradeLinks (sea when both coastal
-> longer reach / river / overland) with volume from populations x proximity x
a political factor (blockaded by war, boosted by an alliance); prosperity =
base + sum of link volumes (hubs get rich); a per-cell wealth field via a new
sCellSettleOwner filled by computeTerritory.
- Prosperity feeds carrying capacity in stepCivilization (K *= 1 +
tradeProsperityWeight*prosperity), so connected coastal/river hubs grow bigger.
- Light feedback in stepConflict (reads last year's economy): trade partners get
a diplomacy attitude nudge (reward alliance); a wealthy weak neighbour raises
war hostility (tempt war).
- Render: a Wealth heat map (wealthColor) + trade-route overlay (sea cyan /
land+river amber) under key Z, a gold wealth dot per settlement in the Civ tab,
a cell-info prosperity/route line. trade* config knobs (no save block).
- test_trade.cpp: links form (sea over longer range), hubs richer than isolated,
war blocks trade, prosperity raises carrying capacity, determinism, RNG
isolation, save->load->recompute parity. All 15 suites green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
18 lines
803 B
C++
18 lines
803 B
C++
#pragma once
|
|
#include <vector>
|
|
#include <cstdint>
|
|
|
|
// Civilization Step 7: trade & economy. Trade routes link nearby settlements (by sea / river / overland),
|
|
// prosperity accrues at well-connected hubs, and prosperity boosts population growth. Like territory and
|
|
// cultures, this is a PURE DETERMINISTIC function of the (saved) settlement set + geography + wars +
|
|
// diplomacy -- recomputed each sim year, not saved (no save-format change), no RNG, rewinds for free.
|
|
|
|
enum class TradeKind : uint8_t { Land, River, Sea };
|
|
|
|
struct TradeLink {
|
|
int a = -1; // settlement index of one endpoint
|
|
int b = -1; // settlement index of the other endpoint
|
|
float volume = 0.0f; // trade volume (drives both endpoints' prosperity)
|
|
TradeKind kind = TradeKind::Land;
|
|
};
|