Cross-Platform Low-Poly RTS Architecture: Determinism, Lockstep, and Performance
\nThis article breaks down the architecture of a cross-platform low-poly medieval real-time strategy game, covering the layered separation of simulation and presentation, a deterministic simulation core based on fixed-point math and fixed ticks, pathfinding with shared flow fields, the trade-offs between deterministic lockstep and state synchronization, mobile rendering budgets, a unified content pipeline for campaign and custom maps, cloud-side support for non-real-time services, and a test-and-tuning loop for release.
\n## 1. Background: Why Classic RTS Games Are Still Hard to Build Today\n\nLow-poly medieval attack-and-defense real-time strategy games have regained attention over the past decade. The core selling point is not visual fidelity but a retro experience with clear rules, tight pacing, no stamina bars, and no in-app purchase acceleration: a match lasts ten to twenty minutes and includes campaign progression, online matches, human-AI co-op, and player-built levels. These design choices place demands on the technical side that are completely different from mainstream “heavy-asset, long-cycle” strategy games.\n\nThe difficulties concentrate in four areas:\n\n1. Cross-platform consistency: the same logic must run on both desktop and mobile, while input methods, compute power, memory, and thermal constraints differ enormously.\n2. Real-time determinism: pathfinding, collision, and attack resolution for hundreds of units must produce identical results on any device; otherwise multiplayer matches suffer from “what you see is not what I see.”\n3. Content throughput: campaign levels and custom maps produced by the editor must be loaded, validated, and distributed reliably.\n4. Short-match pacing: a ten-to-twenty-minute match means every second spent on loading, matchmaking, synchronization, and settlement is perceived by players.\n\nThe sections below follow this order: layered architecture, simulation core, network synchronization, rendering and performance, content pipeline, cloud-side support, and testing and tuning.\n\n## 2. Layered Architecture: Fully Separating Determinism from Presentation\n\nThe most reliable engineering approach is to split the system into three layers that communicate only through explicit data contracts:\n\n- Simulation layer: pure logic that handles resource gathering, unit production, combat resolution, and win/loss determination. It requires no floating-point uncertainty, no engine object dependencies, and no global random state.\n- Presentation layer: animation, effects, audio, and camera. It only reads simulation snapshots and never writes back.\n- Platform layer: input, storage, networking, accounts, and cloud service integration. It flattens differences across systems into a unified interface.\n\nThe pseudocode below illustrates this one-way data flow:\n\ntext\n// Simulation layer: advances at a fixed step, input is a command stream\ntick(dt_fixed):\n for cmd in pending_commands: // commands already sorted by frame number\n apply(cmd)\n update_resources()\n update_combat()\n snapshot = build_snapshot() // read-only output\n\n// Presentation layer: interpolated rendering, no write-back\nrender(alpha):\n state = interpolate(prev_snapshot, snapshot, alpha)\n draw(state)\n\n\nThe key benefit of this structure is that the presentation layer can be replaced arbitrarily without affecting match results. The low-poly style happens to lower presentation-layer cost, letting the team invest the budget in the simulation and network layers.\n\n## 3. Simulation Core: Fixed-Point Numbers, Fixed Steps, and Command-Based Input\n\n### 3.1 Fixed Steps and Command-Based Input\n\nAbstract player actions into commands (selection, movement, construction, training, ability casting), and consume only the command queue sorted by frame number each frame. A match then becomes a replayable command stream, which naturally supports recordings, reconnection after disconnects, and replay verification.\n\n### 3.2 Numerical Determinism\n\nCross-platform floating-point differences are the most common hidden defect in real-time strategy games. The general practice is:\n\n- Use fixed-point numbers for critical values (for example, 64-bit integers with an agreed number of fractional digits);\n- Use a seeded pseudo-random generator for randomness, and never call the global random source;\n- Keep stable ordering rules when iterating containers, avoiding hash-order differences;\n- Use in-house grid/flow-field solutions for physics and pathfinding rather than relying on engine physics.\n\n### 3.3 Spatial Indexing and Pathfinding\n\nWith hundreds of units on screen, naive pairwise collision detection degrades to quadratic complexity. A common industry combination is grid bucketing plus flow-field pathfinding plus local avoidance:\n\ntext\nbuild_flow_field(goal):\n for cell in grid: cell.cost = INF\n queue.push(goal)\n while queue not empty:\n c = queue.pop()\n for n in neighbors(c):\n if passable(n) and cost(n) > cost(c) + terrain_cost(n):\n cost(n) = cost(c) + terrain_cost(n)\n queue.push(n)\n\n\nA flow field is built once and shared by many units. Combined with hierarchical pathfinding (macro path plus micro avoidance), it can reduce pathfinding cost to an acceptable range while keeping results deterministic.\n\n## 4. Network Synchronization: Choosing Between Deterministic Lockstep and State Synchronization\n\nMultiplayer supports 1 to 8 players, and the choice is usually between two paradigms:\n\n| Dimension | Deterministic Lockstep | State Synchronization |\n| —- | —- | —- |\n| Bandwidth | Very low, commands only | Higher, snapshot deltas |\n| Compute | High, full simulation required | Low, local presentation only |\n| Consistency risk | Depends on strict determinism | Depends on sync quality, rollbacks likely |\n| Weak-network behavior | Noticeable stutter | Can be smoothed with interpolation |\n\nThe practical compromise is “lockstep as the default plus keyframe validation”: normally only commands are synchronized, and lightweight state hashes are exchanged periodically. If a mismatch appears, it can be traced immediately to the specific frame and command, which makes fixes easier. On mobile weak networks, command delay compensation and local prediction are added on top to ease input-feel problems.\n\nEngineering details also matter: commands must be idempotent or deduplicable; disconnected players need a hosting/takeover policy; and the settlement phase must treat the simulation layer’s final snapshot as the sole authority, so presentation-layer data never participates in the decision.\n\n## 5. Rendering and Mobile Performance Budget\n\nThe value of the low-poly style is “trading polygon count for style,” which makes the performance budget very clear:\n\n- Geometry budget: keep unit models at low polygon counts, and use shared meshes with instanced rendering to batch the same unit type;\n- Material budget: use as few shared materials as possible to reduce draw-call switches;\n- Effects budget: use object pools for attacks, explosions, and other effects to avoid frequent runtime allocation that triggers garbage collection;\n- Resolution strategy: on mobile, use dynamic resolution or render-scale scaling, prioritizing stable frame time;\n- Heat and battery: cap the number of on-screen effects, and proactively downgrade non-critical particles during long matches.\n\nAn actionable frame-budget breakdown (assuming 60 FPS, 16.6 ms):\n\ntext\nSimulation <= 4 ms\nPathfinding/avoidance <= 3 ms\nRender submission <= 6 ms\nUI and network <= 2 ms\nHeadroom >= 1.6 ms\n\n\nWriting the budget into continuous integration and automatically running a benchmark scene on every commit is an effective way to prevent performance regressions.\n\n## 6. Content Pipeline: Unifying Campaign Levels and the Editor\n\nCampaign progression and player-built levels are essentially the same serialized format of “map data plus trigger scripts plus win conditions.” The recommendation is:\n\n1. Unified data format: maps, unit spawn points, resource points, and triggers use the same readable text or binary structure, which is easy to version;\n2. Sandbox validation: before a custom level loads, run static validation (whether references exist, whether resources are out of bounds, whether scripts loop infinitely) and reject illegal content;\n3. Gradual rollout: release new-version levels to a small audience first, observe crash rate and frame time, then roll out fully;\n4. Replay as test: use command-stream replay as regression cases to verify that balance changes introduce no logic regressions.\n\nLevel scripts should use a restricted, statically analyzable form of expression to avoid the security and stability risks of arbitrary code execution.\n\n## 7. Cloud-Side Support: Moving Non-Real-Time Work to the Server\n\nReal-time matches themselves suit client-side or nearby real-time channels, but many “non-real-time yet important” capabilities fit better in the cloud and can be met with general product categories:\n\n- Object storage: holds map packages, version resources, and replay files;\n- Content delivery network: reduces cross-region download latency;\n- Message queue: decouples asynchronous flows such as matchmaking, settlement, and leaderboard writes;\n- Container platform: hosts matchmaking and validation services, scaling elastically with load;\n- Logging and monitoring/alerting: aggregates crashes, frame time, and synchronization failure rates into an observability loop.\n\nOn Baidu AI Cloud, the above capabilities can be combined by general category: object storage together with content delivery for resource distribution, a container platform for stateless matchmaking and validation services, and the logging and monitoring system for a quality dashboard. Note that specific parameters and pricing should follow the official documentation; this article does not describe any unconfirmed capabilities.\n\n## 8. Testing, Tuning, and the Release Loop\n\n1. Determinism regression: replay the same command stream on different devices and compare final snapshot hashes;\n2. Stress scenarios: build benchmark levels with a thousand units, extreme terrain, and continuous ability casting;\n3. Weak-network drills: inject latency, jitter, and packet loss to validate prediction and compensation strategies;\n4. Observability metrics: frame-time percentiles, synchronization failure rate, matchmaking wait time, and level load time;\n5. Gradual rollout and rollback: release versions by population segment, with automatic rollback on anomalies.\n\n## 9. Conclusion\n\nThe engineering essence of a low-poly medieval RTS game is “trading strict layering and determinism for cross-platform consistency and content throughput.” Decoupling simulation from presentation, making numbers deterministic, turning pathfinding into a shared flow field, handing non-real-time capabilities to general cloud components, and supporting it all with a budgeted performance management approach and a replay-driven testing system makes it possible to reliably deliver a high-quality ten-to-twenty-minute match experience under limited compute and short-match pacing.
