planetsim/src/render/Colors.hpp
Jonas Reith e27b91a128 Civ Step 7: trade & economy
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>
2026-07-01 13:36:41 +02:00

51 lines
2.5 KiB
C++

#pragma once
#include "raylib.h"
#include "PlanetTypes.hpp" // Biome
// Cell color mapping for the viewer. Pure functions of cell properties.
enum class ColorMode { Elevation, Plate, Age, Crust, Biome, Temperature, Precip,
FloraDensity, FaunaDensity, FungaDensity,
Ecoregion, Habitability, Territory, Culture, Wealth,
TempSummer, TempWinter, Seasonality }; // 6 cycles these temp sub-views
Color elevationColor(double e, double seaLevel);
Color plateColor(int id);
Color ageColor(double age, double maxAge);
Color crustColor(bool oceanic);
// Phase-2.5 inland water (lakes): a bright turquoise, clearly distinct from ocean.
Color lakeColor();
// Phase-3 biome palette + display name.
Color biomeColor(Biome b);
const char* biomeName(Biome b);
// Human-readable name of a color mode (for the active-view label).
const char* colorModeName(ColorMode m);
// Phase-3 climate: temperature in deg C (blue cold -> red hot); precip normalized 0..1
// (tan dry -> green -> blue wet).
Color tempColor(double celsius);
Color precipColor(double moist01);
// Seasonality: summer-winter temperature range in deg C (grey calm -> orange extreme).
Color seasonColor(double rangeC);
// Tide level (m), diverging around 0: low tide amber -> high tide cyan. `range` sets the
// saturation scale (meters at which the colour is fully amber/cyan).
Color tideColor(double level, double range);
// Biota density ramps (0..1): flora barren->lush green, fauna pale->amber/red,
// funga pale->violet/brown.
Color floraColor(double d01);
Color faunaColor(double d01);
Color fungaColor(double d01);
// Marine biota density ramps (0..1) -- a distinct sea palette so ocean reads as
// ocean: marine flora deep blue->bright teal/green bloom, marine fauna deep
// blue->cyan->warm. Used for water cells in the flora/fauna views.
Color marineFloraColor(double d01);
Color marineFaunaColor(double d01);
Color ecoregionColor(int id, Biome b, double productivity);
// Habitability heat map (0..1): barren grey -> fertile green/gold (where civilization can thrive).
Color habitabilityColor(double h01);
// Wealth / trade-prosperity heat map (0..1): dim slate -> teal -> bright gold (rich trade hubs).
Color wealthColor(double w01);
// Per-nation territory tint (golden-ratio HSV, offset from plateColor so realms read distinctly).
Color nationColor(int id);
// Per-culture tint (golden-ratio HSV, a different phase than nationColor so cultural blocs read distinctly).
Color cultureColor(int id);