Building a Turn-Based Strategy Map from Public Statistics with AI-Assisted Coding
A practical look at turning a one-sentence goal into a browser-based hexagonal strategy map: aligning more than thirty public statistical sources onto a shared grid, mapping real indicators to familiar game semantics, and using layered rendering, lineage, and human review so AI-generated code stays verifiable.
From a One-Sentence Goal to a Runnable System
One widely shared practice is worth unpacking. A developer stated a single goal: fill a turn-based strategy-game map with real national public statistics. An AI coding tool then worked for about seven hours and produced roughly 45,000 lines of code. The result was an interactive site that could be browsed directly in a browser, with source published under a permissive open-source license.
The value of the case is not the line count. It shows a different engineering cadence: requirements are stated in natural language; scaffolding, the data pipeline, the rendering layer, and the interaction layer are generated by the coding tool; people define constraints and accept the result. Reproducing that pace means translating a vague wish into engineering constraints that can be checked.
Data Layer: How More Than Thirty Public Sources Collapse onto One Map
The original practice connected thirty-one government open-data sources, covering population and housing censuses, regional economic totals, power-plant and energy-facility locations, and natural-disaster events. The hard part was not downloading. It was convergence.
- Semantic alignment. Agencies differ in definitions, years, and administrative levels. A shared metric dictionary has to come first: metric name, unit, statistical year, geographic grain, and the meaning of missing values.
- Spatial alignment. All polygon and point data land on the same hexagonal grid of about 25 kilometers per cell. Aggregation uses area weighting or population weighting so that dropping values on centroids does not bias the map.
- Traceable lineage. Every cell value must answer which source, which edition, and which year it came from. In practice, each data block keeps a source identifier and a version number, and the front end shows them in a hover tooltip.
A schematic data contract looks like this:
{"cell_id": "hex_25km_184233","metrics": {"gdp": { "value": 1.87e11, "unit": "USD", "year": 2024, "source": "regional_accounts" },"pop": { "value": 20110000, "unit": "person", "year": 2024, "source": "census" },"health": { "value": 0.71, "unit": "index", "year": 2023, "source": "public_health" }},"lineage": ["regional_accounts@2024.1", "census@2024.1"]}
Why a Hexagonal Grid
Hexes have a natural advantage in equal-distance adjacency. All six neighbors sit at the same distance, so there is no square-grid ambiguity where a diagonal neighbor is farther away. Diffusion, neighborhood statistics, and pathfinding stay cleaner. Hexes also use fewer edges than triangles and are easier to instance-render than irregular polygons. The cost is a reliable hex index and coordinate conversion, usually axial coordinates plus a cube representation:
// Convert axial (q, r) to cube coordinates for distance and ring queriesconst cube = ({ q, r }) => ({ x: q, z: r, y: -q - r });const distance = (a, b) => {const A = cube(a), B = cube(b);return Math.max(Math.abs(A.x - B.x), Math.abs(A.y - B.y), Math.abs(A.z - B.z));};
Indicator Mapping: Turning Statistical Definitions into Player Semantics
The cleverest step in the original practice was replacing the five classic strategy outputs with real statistics. Gold maps to gross regional product (a national top-bar total of about 29.3 trillion U.S. dollars). Food maps to employment in agriculture, forestry, fishing, and hunting. Productivity maps to employment in manufacturing, construction, and mining. Science maps to employment in professional scientific services and information. Culture maps to employment in arts and entertainment. Even “livability” is replaced by a health index published by public-health agencies.
This mapping is not decoration. It is a cognitive design: users reuse game intuition they already have, so the cost of understanding drops sharply. Similar systems should keep three rules: stay semantically close without misleading (the UI must state the real definition), compare only after units are aligned, and clip extremes with quantiles so long tails do not flatten the color scale.
Lens System and Layer Scheduling
The original practice offered nineteen data lenses in seven groups, switching among layers such as income, education, broadband access, religious composition, and hazard exposure. In engineering terms that is one geometry, many attribute sets, and pluggable color scales:
- Load geometry once. Lazy-load attributes per layer, and on switch update only the instance attribute buffer.
- Use accessibility-friendly sequential or diverging ramps that remain distinguishable for color-blind viewers.
- Declare layer metadata in one place so a new lens does not require rendering-code changes.
const LAYERS = [{ id: "income", group: "economy", field: "income_median", palette: "seq_viridis", label: "Median income" },{ id: "hazard", group: "risk", field: "hazard_index", palette: "div_redblue", label: "Hazard exposure" }];
Beyond the Grid: Drawing Flows
A static grid only shows stocks. The original practice also overlaid flows. Using freight statistics from the federal highway authority, it drew the top forty interstate commercial corridors in the country. The New York–Boston corridor, about 306 kilometers, carried roughly 61.9 billion U.S. dollars of freight per year. Arcs of this kind snap endpoints to cell centers, map value to line width and opacity, and support screen-space picking so a click can drill into a city view.
Performance and Maintainability
Forty-five thousand lines stay runnable through layering and precomputation. The server cleans and aggregates offline and emits quantized binary or vector tiles. The front end instance-draws tens of thousands of hexes, clips to the viewport, and drills down by level of detail—national, regional, then city. Static assets sit in object storage behind a content delivery network. A container platform hosts build and preview environments, and logging plus monitoring track render error rates and time to first paint. These are generic cloud capabilities; choose them according to the stack the team already runs.
A Method for Human–AI Collaboration
What transfers from this case is the collaboration pattern. Fix the data contract and acceptance criteria first, then let the coding tool advance module by module—collection, cleaning, gridding, rendering, interaction, and documentation—and check each step against a runnable result. Treat “it runs” as the only hard gate, and replace verbal description with regression on real data. Finally, complete source notes and the open-source license so others can reuse and audit the work.
Closing
The lesson of one map is that competition in data visualization has moved from drawing technique to data governance and semantic design. State the definitions clearly, keep lineage complete, and make interaction smooth. The remaining repetitive work can go to an AI coding tool.
