Flatland3 — Initial Vision & Architecture Plan
Current play client (2026-07): flatland3-gfx is the only maintained interactive client (Macroquad + egui). Ratatui map play and flatland-dev are retired. The TUI references in this chapter describe early development intent — see Macroquad Graphical Client.
1. Executive Summary
Flatland3 is a multiplayer online game designed for many concurrent players in a single continuous world with real-time streaming at 30–60 ticks per second. Development is server-first: all world rules, systems, and simulation logic are built and validated on the server before any graphical client exists.
The only client during early development is a TUI (terminal UI) for humans and agents (scriptable CLI, JSON output).
The runtime is Rust for speed, safety, and efficient concurrency.
World model (current)
- One global world per live deployment — operator-controlled region workers
- Region workers partition space for scale (operator-controlled, same ruleset)
- World Building API — grow terrain, resources, underground / underwater / sky strata via CLI and agents
- Segment pipeline — draft → review → approve → publish → deploy; community builders with permissions
- Open source (later) — self-hosters run separate realm deployments
See 01-global-world-architecture.html for full topology.
2. Core Design Principles
| Principle | Description |
|---|---|
| Server authority | All gameplay outcomes decided on the server. |
| Protocol first | Networking hardened before feature breadth. |
| One world | Continuous geography; players walk, dig, swim, fly within height caps. |
| Scaled by regions | Dynamic chunk-assigned workers; split/merge from day one (01 §3.4). |
| Hot world deploy | Versioned segments; rolling apply without downtime (01 §5.6). |
| Built to grow | World content is versioned segments with review/deploy. |
| Agent-operable | World build, ops, and play exposed via stable CLIs. |
| Observable by default | TUI + metrics + tracing for sim and pipeline. |
| Incremental complexity | Thin vertical slice first: connect → move → harvest → persist. |
| Unique items only | No BiS gear chase — every mint is a permanent unique instance (18). |
| Interest horizon | AOI-filtered tick streams (06). |
| Exploration knowledge | Per-player cartography ledger (06). |
3. High-Level Architecture
┌──────────────────────────────────────────────────────────────────────────┐
│ CONTROL PLANE — accounts, economy, persistence, audit, broker indices │
└───────────────────────────────┬──────────────────────────────────────────┘
│
┌───────────────────────────────▼──────────────────────────────────────────┐
│ WORLD BUILD — segment API, validation, review, publish, deploy │
└───────────────────────────────┬──────────────────────────────────────────┘
│ world manifest
┌───────────────────────────────▼──────────────────────────────────────────┐
│ SIMULATION CLUSTER — gateway + region workers (spatial shards) │
│ One continuous (x,y,z) world · 30–60 Hz per active region │
└───────────────────────────────┬──────────────────────────────────────────┘
│
TUI / clients
3.1 Region worker
- Owns a spatial bounds in the global world
- Tick loop, entity registry, AOI, combat, harvesting (active regions)
- Reads deployed world manifest for terrain, resources, zones
- Region handoff when players cross boundaries (gateway-assisted)
3.2 Control plane
- Accounts, characters, inventory, banks, brokers
- Cartography ledger, skills, death penalties
- World segment catalog (published versions)
- Anti-cheat, audit, bans
3.3 World build service
- CRUD for segments (terrain, resources, spawns, structures)
- Vertical strata — underground, surface, underwater, sky (height limits in config)
- Limited resources per segment definitions
- Permissioned community access + review / approve / deploy
4. Communication Protocol (Priority #1)
4.1 Client ↔ gateway
| Layer | Responsibility |
|---|---|
| Transport | QUIC preferred |
| Session | Auth, protocol version |
| Tick stream | AOI-filtered deltas @ 30–60 Hz |
| Intent channel | Movement, actions (sequenced) |
| Reliable RPC | Trade, craft, chat, admin |
| Bulk | Region enter, reconnect snapshot |
4.2 Internal (cluster)
- Gateway ↔ region workers: entity migration, interest transfer
- Region ↔ control plane: inventory, economy, persistence RPC
- World build ↔ control plane: deploy notifications, manifest versions
4.3 Open protocol decisions
5. Performance Targets
| Metric | Target | Stretch |
|---|---|---|
| Region tick rate | 30 Hz | 60 Hz |
| AOI broadcast | Core ring @ tick rate | Horizon LOD |
| Intent → receipt | p99 < 20 ms LAN | p99 < 50 ms WAN |
| Players per active region | 100 | 500+ |
| Region handoff | < 200 ms | < 100 ms |
| Reconnect resync | < 3 s | < 1 s |
Dormant regions (no players) do not tick — saves CPU as world grows.
6. Persistence Model
| Class | Owner | Examples |
|---|---|---|
| Global canonical | Control plane | Accounts, bank, brokers, cartography |
| Region runtime | Region worker | Entity poses, combat, ground loot |
| World manifest | Control plane | Published segments, terrain, resource defs |
| Segment drafts | World build | Pre-approval content |
Checkpoint on logout, death, region exit; central DB is source of truth for durable player/world state.
7. Game Systems (summary)
Detailed in topic docs — all execute on region workers unless noted.
| System | Doc |
|---|---|
| Coordinates, AOI, cartography | 06 |
| Death, corpse, penalties | 07 |
| Inventory, banks, currency | 08 |
| Crafting graph | 09 |
| Workers & factory automation | 13 |
| Justice, wanted, bounties | 14 |
| Survival, damage, durability | 15 |
| Profile & innate abilities | 16 |
| Economy, brokers, stalls | 10 |
| Movement, attributes, FOV | 11 |
| Combat | 12 |
| World build & regions | 01 |
Travel: continuous movement, region handoffs, and portals within the world.
Economy: brokers per town/region in the same world; cross-region price quotes = travel arbitrage.
8. TUI Client (Co-developed)
- Play:
flatland— connect, move, inventory, combat - World ops:
flatland-world— segments, terrain, deploy (permissioned) - Agent mode: JSON on all commands
9. Phased Goals
Phase 0 — Foundation
Phase 1 — Single worker + chunk model
Phase 2 — Control plane + dynamic regions
Phase 3 — World build + hot deploy
Phase 4 — RPG loop
Phase 5 — World growth
10. Rust workspace
See 01-global-world-architecture.html §8 — region-worker, gateway, control-plane, world-build.
11. Security & trust
- Single operator cluster — no untrusted sim hosts
- Community builders: draft only until review
- Signed published manifests; workers reject undeployed drafts
- Central audit for economy and rare items
12. Observability
- Per-region tick lag, AOI size, handoff latency
- World deploy pipeline metrics
- Trace correlation across gateway → region → control plane
13. Open questions
Resolved (2026-07-06): Chunk 16 m, water zones+currents, deploy push entities, tick 30→60 Hz — see 01 §11.
Chunk size16 mWater simZones + currents (01)Deploy crushPush/relocate (01)Fixed timestep30 Hz launch, 60 Hz when stable (01)
14. Success criteria (server-first)
- Multi-region handoff stable under packet loss
- 100 bots/region @ 30 Hz
- Full loop: harvest → craft → trade → die → recover corpse
- World segment: validate → publish → deploy → playable in sim
- TUI + agents drive play and world build without raw protocol hacks
15. Document index
| Doc | Purpose |
|---|---|
00-initial-vision.html |
This document |
01-global-world-architecture.html |
Global world, regions, world build pipeline |
06-visibility-maps-and-coordinates.html |
AOI, cartography, coordinates |
07-death-and-respawn.html |
Death, corpse, penalties |
08-inventory-carriers-and-storage.html |
Inventory, banks |
09-crafting-and-recipes.html |
Crafting graph |
10-economy-and-markets.html |
Markets, brokers |
11-entities-attributes-and-movement.html |
Orientation, movement, attributes, FOV |
17-enchanting-and-item-modifiers.html |
Enchanting, item instance modifiers, combat procs |
18-unique-items-and-procedural-economy.html |
Unique instances, procedural mint, NPC settlement crafting |
19-npcs-and-creatures.html |
Unified NPC/creature defs, behavior, schedules, loot, LLM |
20-buildings-schematics-and-construction.html |
Schematics, plot prep, phased build, rooms, fixtures |
manifest.json |
Spec site order |
../docs/spec/ |
Published specification website |
Appendix A — Glossary
| Term | Definition |
|---|---|
| World | Single continuous game universe per deployment |
| Region | Runtime chunk group on a worker; splits/merges dynamically |
| Chunk | Stable spatial unit for terrain, deploy, and ownership |
| Deployment | Versioned bundle of segment publishes hot-applied to sim |
| Segment | Authored world content unit (terrain, resources, …) |
| Control plane | Accounts, economy, persistence, deploy catalog |
| Region handoff | Server-side authority transfer at region boundary |
Realm (w) |
Deployment id; 0 = official world; OSS self-host = other w |
| AOI / Horizon | Network interest filter (06) |
| WorldCoord | (x, y, z, w, t) — t = 0 |