You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit dfe1659
Browse filesBrowse the repository at this point in the historyBrowse files
feat: add architecture, nations, save/load, and terrain documentation
- Introduced architecture overview detailing high-level data flow and directory structure.
- Documented nation system including spawning pipeline, nation class, political map overlay, and configuration.
- Added save/load system documentation outlining save format, API, and IndexedDB schema.
- Detailed terrain generation pipeline stages including elevation, temperature, humidity, rivers, biomes, resources, and strategic points.
- Implemented NationPanel component for displaying nation details and TileInspector for tile information.
-[x] Political map overlay with territory colouring
173
218
174
219
### Phase 3 — Expansion & Borders
175
220
@@ -188,7 +233,7 @@ sovereign/
188
233
-[ ] God Mode (intervention tools)
189
234
-[ ] Historical timeline & statistics
190
235
191
-
> See individual phase docs in `docs/` for details.
236
+
> See individual phase docs in [`docs/`](docs/) for details.
192
237
193
238
---
194
239
@@ -223,4 +268,4 @@ Contributions are welcome! The project is in early development.
223
268
224
269
Built with [Electron](https://www.electronjs.org/) · [React](https://react.dev/) · [TypeScript](https://www.typescriptlang.org/) · [simplex-noise](https://github.com/jwagner/simplex-noise.js)
Sovereign is a procedural geopolitical simulation built with **React 18 + TypeScript + Canvas 2D**, shipped as both an **Electron** desktop app and a **static web build** via Vite.
With 4 million tiles (2000 × 2000), storing each tile as a JS object would create massive GC pressure. Instead, each property is a flat typed array:
88
+
89
+
```ts
90
+
elevation: Float32Array// 4M × 4 bytes = 16 MB
91
+
temperature: Float32Array// 16 MB
92
+
humidity: Float32Array// 16 MB
93
+
biomeIds: Uint8Array// 4 MB
94
+
riverMask: Uint8Array// 4 MB
95
+
resourceType: Uint8Array// 4 MB
96
+
resourceDensity: Uint8Array// 4 MB
97
+
ownership: Uint8Array// 4 MB
98
+
// Total: ~68 MB
99
+
```
100
+
101
+
The `WorldMap.at(x, y)` method composes a `TileInfo` object on demand, so the ergonomic API exists without the memory overhead.
102
+
103
+
### Web Worker for Generation
104
+
105
+
All terrain generation (elevation, temperature, humidity, rivers, biomes, resources, strategic detection, and ImageData rendering) runs in a dedicated Web Worker. Results are posted back as **transferable**`ArrayBuffer`s — true zero-copy transfer, not structured clone.
106
+
107
+
### Chunked Rendering
108
+
109
+
The map is split into 64 × 64 tile chunks, each rasterised into an `ImageBitmap`. The renderer only draws chunks overlapping the camera viewport (frustum culling). View switching swaps cached bitmap sets into the same chunk layout without re-rasterising.
110
+
111
+
### Zustand State Store
112
+
113
+
A single zustand store (`GameStore`) holds all application state:
The JSON header holds metadata (seed, dimensions, strategic points). The binary payload is the concatenated typed array buffers. This avoids Base64 overhead and handles 60+ MB save files efficiently.
0 commit comments