Architecture and Implementation of a Real-Time 3D Warship Simulation
This article treats a highly interactive 3D warship combat demo as a real-time simulation system. It covers determinism, input latency, presentation, and tiered AI, then walks through the scene pipeline, action state machine, input buffering, local two-player flow, performance budget, optional cloud support, and an acceptance checklist.
1. From Gameplay Description to Technical Requirements
The source material describes a highly interactive 3D combat demo: two selectable units, a rainy-night stage, three AI difficulty levels, local two-player play, best of three, guard, throws, jumps, dashes, airborne states, combo cancels, directional specials, a full-meter super, close-up shots, pause, and a match result screen. Abstracted, this is a real-time interactive simulation. Its technical requirements come down to four points:
- Determinism: the same input sequence must produce the same state evolution. Otherwise replay, regression testing, and two-player sync have no foundation.
- Responsiveness: the delay from input to visual feedback must be stable and controllable. Action links (cancel windows) depend on precise frame counts.
- Expressiveness: logical state must translate without loss into animation, particles, and camera language.
- Tiered difficulty: AI difficulty is not a numeric scale. It is a layering of decision capability.
With those four points as the through-line, the warship theme is only a presentation skin. Deck, bridge, sea surface, rain curtain, and lighting can be replaced without changing the logic core. That decoupling is what a simulation system should aim for.
2. Scene and Asset Pipeline
A rainy-night stage is useful because it stresses three pipelines at once: lighting, transparency, and post-processing.
- Geometry and materials: hard surfaces such as a hull suit modular breakdown (hull segments and reusable side structures) with physically based material parameters (metalness, roughness, and normals). That avoids painting a unique texture for every part.
- Lighting strategy: a night scene should rely on a few key lights (searchlights, deck lights, and rim light on the command tower) plus ambient light. Dynamic light count must have a hard cap, or frame rate on mobile becomes unpredictable.
- Rain and water: a rain curtain is usually approximated with particles or screen-space streaks; water uses scrolling normals plus a reflection approximation. Both are degradable and should be switchable off on low-quality tiers.
- Post-processing: bloom, tone mapping, and a light depth of field form the atmosphere, but they must stay separate from the UI layer so the result screen is not blurred with the scene.
Suggested asset pipeline: keep source assets in object storage, publish build artifacts under versioned directories, and at runtime use on-demand loading plus reference-counted unload driven by a scene manifest. When switching stages, unload first and then load. That significantly lowers peak memory.
3. Action System: State Machine, Cancel Windows, and Airborne State
Combat feel comes from the state machine, not from the number of moves.
States: Idle / Walk / Dash / Jump / Fall / Guard / Hitstun / Launch (airborne) / Knockdown / KOTransition conditions: input command + cancel set allowed by the current state + frame countExample cancel sets:Normal1 -> {Dash, Jump, Guard, Special}Normal2 -> {Special, Super}Special -> {Super} // only when the meter is full and the move connects
Three details matter:
- Frame windows, not time windows: hitstun, invulnerability, and cancel checks are measured in logic frames. Rendering frame rate does not change the outcome.
- Throws bypass guard: a throw should skip the guard check, but it still needs startup frames and a range check, and it must be interruptible while the attacker is being hit. Otherwise it becomes an unsolvable loop.
- Airborne state and combo count: the airborne state needs its own gravity and a limit on actions. The combo counter scales down damage and hitstun so infinite combos cannot continue.
4. Input Layer: Buffer, Command Recognition, and Camera Direction
Reliable directional specials depend on the input layer, not on visual effects.
- Input buffer: keep a ring buffer of about 8–12 frames that records directions and timing. Command recognition slides across that buffer and allows tolerance (one extra or one missing frame still matches).
- Direction encoding: use an eight-way numeric pad (1–9), not angles. Matching and debugging stay simpler.
- Meter and super: the meter accumulates from three sources: hits landed, hits taken, and time. When full, the super adds a short close-up. The camera must read logical state only and must not feed back into hit detection.
- Pause: pause must freeze the logic clock, animation blending, and audio together. On resume, discard input accumulated during the pause so the game does not fire a move the moment it unpauses.
5. Tiered AI: Treat Difficulty as Capability
Difficulty should not be a damage multiplier. A practical split looks like this:
| Dimension | Easy | Standard | Hard |
|---|---|---|---|
| Decision period | Long (many frames) | Medium | Short |
| Input precision | Tolerant matching | Exact | Exact, with buffered pre-input |
| Guard tendency | Low | Medium | High, including throw mix-ups |
| Resource management | None | Saves meter | Reads distance and plans combos |
Implementation centers on a behavior tree plus a blackboard. The blackboard stores distance between the two sides, states, meter, and remaining time. The tree chooses approach, poke, guard, combo, or super. All randomness uses a seedable pseudo-random source so replays stay consistent.
6. Local Two-Player and Round Flow
Local two-player play is an input arbiter: two input sources merge into the same logic frame. The logic core does not distinguish human from AI; AI is simply another input source. Model the round flow explicitly:
Intro -> Select -> RoundStart -> Fighting -> RoundEnd -> (next round | MatchEnd) -> ResultAny state -> Paused -> previous state
Best of three, win/loss settlement, and draws all converge in RoundEnd. Judgment logic should not be scattered through the combat code.
7. Performance Budget and Engineering
- Split the frame budget: set separate ceilings for logic, animation, rendering, and UI. When a ceiling is exceeded, degrade effects and shadows first, then consider lowering resolution.
- Object pools: pool projectiles, particles, and damage numbers. Avoid frequent allocation at runtime.
- Instancing and LOD: draw repeated hull parts with instancing, and switch distant views to low-poly models.
- Deterministic regression: record the input stream and compare replays. That is the only reliable way to catch intermittent “feel” bugs.
8. Cloud-Side Support (Generic Categories)
If the system needs external distribution and ongoing iteration, generic Baidu AI Cloud capabilities can support it: object storage for asset packs and versioned artifacts, a container platform for builds and replay tests, a message queue to decouple build and release, and logging plus monitoring and alerts for crash rate, load time, and frame-rate distribution. These are common industry capability combinations and do not depend on any proprietary interface contract.
9. Acceptance Checklist
- The same input replay matches frame by frame.
- The three AI tiers are distinguishable by win rate and decision frequency.
- Cancel windows, throws, and the airborne state each have independent test cases.
- Pause and resume neither drop input nor swallow frames.
- Low-quality tiers can disable the rain curtain and reflections without changing hit detection.
- Result and round flow have no deadlocks.
Fully separating the presentation layer from the logic layer is the basic condition for this kind of real-time 3D interactive system to look striking on first view and still feel solid in play.
