Warship 3D Simulation and Combat Training System: Architecture and Implementation
This article analyzes the architecture of real-time 3D warship simulation and combat training systems and explains why impressive visuals often hide deep problems once live combat begins. It identifies four structural gaps: between visual quality and interaction quality, between rule design and numerical implementation, between AI capability and its scalability, and between single-machine demos and multi-client consistency. It then lays out a layered architecture that separates simulation logic from rendering, and covers fixed-timestep loops, configuration-driven design, scene validation, movement and animation state machines, frame-data-driven hit detection, a three-tier AI design, a match state machine for best-of-three play, and the presentation layer for cameras, pause, and post-match review. Finally, it describes the engineering practices needed to turn a demo into a maintainable system: determinism, performance budgets, observability, an acceptance checklist, and a troubleshooting guide.
1. Background: Stunning Visuals, Broken Combat
With 3D graphics, simulation, and real-time competitive gameplay spreading quickly, developers can now use an AI coding tool to turn a natural-language requirement into a working 3D real-time application prototype within minutes. These prototypes usually include:
- Opening screens and character showcases
- Single-player combat
- Three AI difficulty levels
- Local two-player versus with best-of-three
- Defense, throws, jumps, dashes, floats, and combo cancels
- Directional special moves, full-energy super moves, and cinematic camera shots
- Pause and win/loss resolution
Such prototypes are commonly described as “stunning on the opening screen, with problems surfacing all at once once combat begins.” The same gap appears in the development of 3D warship simulation and combat training systems. Hull appearance, sea-and-sky lighting, and interface art can reach demo quality in a short time, but the real difficulty lies in ship handling, situational awareness, engagement decisions, and consistency over long confrontations.
This article uses a 3D warship simulation and combat training system as its subject. Referencing the capability range covered by such prototypes, it systematically discusses the architecture, implementation essentials, and engineering practices of real-time combat systems.
2. Problem Definition: Four Kinds of Gaps in Real-Time Simulation
2.1 The Gap Between Visual Quality and Interaction Quality
Static visuals show only the final result. An opening animation, for example, plays along a preset camera path with lighting, composition, and materials already fixed, so every render is identical. Real-time combat is the opposite: the result is determined jointly by player input, AI decisions, random numbers, and time steps. No matter how polished a static scene is, it cannot hide defects at the rules level. Evaluation of a warship simulation therefore has to shift from “does it look good” to “is the situation credible, is adjudication consistent, and is the process reproducible.”
2.2 The Gap Between Rule Design and Numerical Implementation
Rules like “best of three” and “the first side to sink the other wins” are, in essence, win/loss scoring and end-condition logic inside a match state machine. If you simply accumulate a floating-point “durability value” and never explicitly evaluate victory when it reaches zero, you end up with cases where both sides hit zero at once, no one is judged when time runs out, and players can still act after the match ends. Warship combat involves multiple states such as hull damage, flooding, fire, and weapon failure, so there are even more rule boundaries. Any win/loss condition must therefore map to an explicit state transition.
2.3 The Gap Between AI Capability and Its Scalability
The AI in such prototypes is often a single rule: “fire when the target is closest.” The moment you add multi-role tasks like formation, escort, or anti-submarine warfare, this logic becomes hard to maintain. More importantly, difficulty adjustment cannot rely on numerical bonuses alone. In real warship training, “easy” should mean slow reactions and narrow judgment, while “hard” should mean comprehensive information and full coordination.
2.4 The Gap Between a Single-Machine Demo and Multi-Client Consistency
A successful demo run does not guarantee stable reproduction. Networked simulation requires every client to produce the same result from the same input. Floating-point error, out-of-sync random numbers, and variable frame steps all cause state drift. Warship formation combat inherently involves multiple parties, so determinism must be designed in from the very first line of code.
3. Overall Architecture: Separating Logic from Presentation
3.1 Layered Responsibilities
A real-time simulation system is usually divided into five layers, each with a single responsibility and a one-way dependency:
| Layer | Main Responsibility | Design Notes |
|---|---|---|
| Input layer | Capture input (keyboard, gamepad, instructor commands, data playback) | Hide device differences; tag input with timestamps |
| Simulation layer | Ship movement, situational awareness, engagement adjudication, win/loss determination | Fixed timestep, deterministic, no direct access to render objects |
| Presentation layer | Rendering, animation, camera, audio, UI | Interpolates over simulation state; never changes rules |
| Resource layer | Scenes, models, materials, animations, configuration | Checklisted validation, version-traceable |
| Support layer | Logging, metrics, monitoring, replay | Full-chain observability |
3.2 The Fixed-Timestep Loop
The foundation of separating logic from presentation is that the simulation layer advances in fixed timesteps. The following sketch fully decouples simulation from rendering:
FIXED_DT = 1.0 / 60.0 # Logic tick; decoupled from the render frame rateMAX_CATCHUP_STEPS = 5 # Prevent the "spiral of death": drop backlog when behind rather than catching up foreveraccumulator = 0.0def frame(real_dt):global accumulatorreal_dt = min(real_dt, 0.25) # Stall guard: keep the logic from running wild when switching back to the windowaccumulator += real_dtsteps = 0while accumulator >= FIXED_DT and steps < MAX_CATCHUP_STEPS:simulation.step(FIXED_DT) # Advance simulation: control, perception, engagement, adjudicationaccumulator -= FIXED_DTsteps += 1if steps == MAX_CATCHUP_STEPS:accumulator = 0.0 # Too much backlog: reset and prioritize interaction responsivenessview.render(simulation.state) # Presentation layer reads the snapshot and interpolates
This structure yields three benefits:
- The same input sequence produces the same simulation result on both a 60 Hz and a 144 Hz screen
- The simulation layer holds no render objects, which makes headless runs and automated testing easy
- Frame-rate fluctuations affect only visual smoothness, not adjudication
3.3 Configuration-Driven Design
Ship parameters, weapon ranges, damage, and AI strategy parameters should all be externalized as structured configuration. This lets you adjust training difficulty and scenarios without touching code. For example:
{"ship": { "maxSpeed": 30.0, "turnRate": 1.2, "hullPoints": 100 },"weapon": { "range": 20.0, "arc": 60.0, "reloadTime": 5.0, "damage": 25 },"aiProfile": { "tier": "standard", "reactionDelaySteps": 12, "heuristicDepth": 2 },"match": { "mode": "best_of_three", "timeLimit": 180 }}
It is advisable to put configuration under version control together with resources and validate it at load time, checking value ranges, whether dependencies exist, and whether required fields are missing.
4. Scene Construction: Designing and Validating a Rainy Night Deck
The rainy-night rooftop stage in such prototypes happens to correspond to the most representative environment in warship simulation: a rainy night deck. Rain curtains, wet reflections, a swaying deck, and light scattering in the rain together form a typical nighttime navigation environment.
4.1 A Three-Layer Scene Structure
| Layer | Contents | Purpose |
|---|---|---|
| Visual layer | Hull model, deck, railings, sea and sky, rain and fog, lighting | Presentation |
| Physics layer | Deck colliders, railing blockers, water regions, climbable structures | Prevent clipping and illegal movement |
| Rules layer | Boundary volumes, spawn points, hazard zones, timing anchors | Adjudication and constraints |
The “character walking through walls” and “falling off the map” issues common in prototypes almost always come from building only the visual layer while omitting the physics and rules layers. In a warship scene, the physics layer should also include deck height changes and roll caused by ship motion.
4.2 Scene Validation Checklist
- Consistent scale: One unit equals how many meters, consistent across the whole scene
- Coordinate conventions: Forward, up, and right axis conventions are unified; model facing matches movement direction
- Fitted colliders: Colliders align with visible geometry; thin structures like railings are replaced with simplified boxes
- Closed boundaries: The scene perimeter has impassable boundaries to prevent leaving the map
- Predictable lighting: Rainy night scenes must define a clear key light (searchlights, sidelights) and fill intensity so that key targets remain recognizable
- Performance budget: Rain, fog, and water surfaces carry high transparency and particle costs, so tiered degradation strategies are needed
5. Character Movement and the Animation State Machine
The character abilities in the prototype (jump, dash, defense, throw, float, combo cancel) map to movement and posture control at the warship level. Ships do not jump, but acceleration is limited, turning has inertia, and posture is affected by sea conditions. The engineering essence of both is the same: constrain “continuous input” into “controlled posture,” and guarantee predictability between input and presentation.
5.1 Root Motion and Procedural Correction
Animation-driven displacement (root motion) keeps presentation natural, but in combat it easily drifts from the actual speed, producing “it looked like a hit but nothing was registered.” A common compromise is:
- Movement displacement is computed by the motion model
- Animation handles only posture
- Foot-to-deck contact is corrected procedurally
5.2 State Definitions
| State | Entry Condition | Interruptible |
|---|---|---|
| Idle | No input and speed below threshold | — |
| Moving | Directional input | Interrupted by defense or attack |
| Dash | Dash key pressed and off cooldown | Interrupted when hit |
| Defense | Defense key pressed and in a defendable state | Cannot be canceled actively |
| Hitstun | Effectively hit | Cannot act until hitstun ends |
| Knocked down | Durability at zero or hit by a knockdown attack | Invulnerable while down; has invincibility frames on wake-up |
Transitions between states must converge: any state must be able to return to idle once time runs out or an external event arrives, and no “dead state” is allowed. In warship systems, persistent states such as “damaged,” “flooding,” and “weapon unavailable” must also be separated from the state machine and maintained independently as flags.
6. Hit Detection and Combos: A Frame-Data-Driven Combat Core
6.1 Hitboxes and Hurtboxes
Each attack action is described by an “active-frame window + hitbox,” and the target is described by a “hurtbox.” A hit registers only when, within the active frames, the two intersect and the target is in a hittable state.
The same holds in warship systems: a missile resolves a hit only when its “terminal activation window” overlaps the “target’s detectable region.” Firing too early or too late means it can be jammed by electronic countermeasures, intercepted by close-in weapons, or evaded by target maneuvering. Engagement adjudication should therefore use a combination of “window + geometry + state,” not “hit if within range.”
6.2 Frame Data and Cancel Windows
It is recommended to write each action as structured data:
| Action | Startup | Active | Recovery | Cancelable Into |
|---|---|---|---|---|
| Light attack | 4 | 3 | 10 | Normal attack |
| Heavy attack | 10 | 4 | 20 | Special move |
| Dash attack | 6 | 5 | 14 | Special move |
| Throw | 5 | 2 | 20 | Not cancelable |
| Special (directional combo) | 8 | 6 | 24 | Super move |
6.3 Cancel Detection Code
def can_cancel(attacker, action_id):move = attacker.move_table[action_id]# Allow chaining only once the current action has entered its cancel windowif attacker.current_frame < move.cancel_from:return False# Cancel into the target action while keeping the running combo countattacker.switch_action(move.cancel_into, keep_combo=True)return True
The key to this design is that whether a combo holds is decided by numerical data, not hard-coded in logic. A designer or instructor who tweaks a startup frame can change the entire combat rhythm.
6.4 Floats and Hit States
Float effects correspond to carrier-based aviation or vertical-maneuver scenarios and can be abstracted as a state that “leaves the regular hit-detection layer”:
- During a float, hit detection switches to the airborne hurtbox set
- A landing-recovery window is introduced on touchdown to prevent infinite combos
- After a knockdown, the target enters knockdown protection and is granted brief invincibility on wake-up
These rules must be expressed as explicit fields in the state machine and backed by automated test cases to avoid edge cases such as “infinite combos” or “no chance to counterattack.”
7. AI Layered Architecture and Three Difficulty Levels
7.1 Perception–Decision–Execution Layers
A reliable AI should have three layers and align with the player through a single input interface:
- Perception layer: Outputs only “observable information,” such as the bearing and range of targets detected by radar and shared intelligence from formation members. The AI must not read the player’s true coordinates; insufficient information must go through “prediction + noise.”
- Decision layer: Uses a behavior tree or finite state machine, with common task nodes including patrol, search, approach, hold formation, evade, and coordinated focus fire. Higher difficulty can increase decision depth so the AI anticipates several steps ahead.
- Execution layer: Translates decisions into the same control input as the player, including direction, attack, defense, and skills. The AI and the player then share the same physics and rules, avoiding the imbalance of “the AI ignores physics.”
7.2 Differentiated Design for Three Difficulty Levels
| Dimension | Easy | Standard | Hard |
|---|---|---|---|
| Reaction delay | About 0.4–0.6 s | About 0.2–0.3 s | Near the human limit |
| Observation range | Close-range visual only | Effective radar range | Radar + formation-shared intelligence |
| Decision depth | Greedy: picks only the current best option | Anticipates 1–2 steps | Anticipates 3+ steps, with risk estimation |
| Skill combos | Single attack | Attack and defense combos | Combo cancels and special-move chaining |
| Resource management | Never uses energy even when it overflows | Uses it above a threshold | Plans energy allocation by battle situation |
| Information use | Ignores player history | Tracks player habits | Builds a player behavior model and counters it |
Difficulty differences should manifest as “information and planning ability,” not simply health or damage multipliers. The latter strips training of its guidance value: trainees cannot tell whether they lost because of a judgment error or because of numerical suppression.
7.3 Decoupling Difficulty from Training Scenarios
A more common practice in warship training is that an instructor specifies the “blue force” composition, initial situation, and AI tier for each scenario, and the system loads configuration accordingly. This lets one engine support basic handling, formation coordination, emergency response, and other scenarios without separate development for each.
8. Two-Player Combat: Local Versus, Best-of-Three, and the Match State Machine
8.1 Local Two-Player
Local two-player requires the system to capture two input sources simultaneously and normalize each one separately (gamepad stick dead zones, keyboard repeat rates). For example:
inputs = {"p1": input_source.read(device_id=0),"p2": input_source.read(device_id=1),}simulation.step(FIXED_DT, inputs)
8.2 The Best-of-Three State Machine
“Best of three” is a match constraint: the first side to win two rounds ends the match, so there are at most three rounds. It is advisable to manage this with an explicit state machine:
class MatchState:LOBBY = "ready"ROUND_INTRO= "round_intro"FIGHTING = "fighting"ROUND_END = "round_end"MATCH_END = "match_end"def advance_round(match, winner):match.score[winner] += 1if match.score[winner] >= match.wins_needed:match.state = MatchState.MATCH_ENDelif match.round_index >= match.max_rounds:match.state = MatchState.MATCH_END # Draw-rule fallbackelse:match.round_index += 1match.state = MatchState.ROUND_INTRO
Edge cases that need extra handling:
- When both sides are sunk within the same logic frame, resolve by a preset priority or judge it a draw
- When a round’s time runs out, compare by remaining durability percentage
- Energy, state flags, and timers must be reset between rounds, but the overall score is preserved
9. Presentation Layer: Cameras, Pause, and Post-Match Results
9.1 Cinematic Cameras
When a special or super move is released, the common approach is to briefly slow time, cut to a preset camera position, and synchronize with depth of field and audio-visual cues. In implementation, the camera controller listens for a “super move released” event and, when “not paused” and “no higher-priority camera is active,” takes over the camera and smoothly hands it back when the sequence ends. In warship scenarios, this corresponds to observation viewpoints at key moments such as torpedo hits or missile terminal guidance.
9.2 Pause
The essence of pause is to freeze the simulation clock, not merely to stop rendering:
- While paused, accumulated time no longer increases and logic ticks do not advance
- The input buffer is cleared to avoid firing queued actions the instant play resumes
- Timers, cooldowns, and AI decision queues are frozen in sync
- On resume, input must be resynchronized to prevent state jumps
9.3 Results and Review
The win/loss result should not merely show “win/loss” but should output structured data suitable for review:
{"matchId": "m-20240718-001","rounds": [{ "round": 1, "winner": "p1", "durationSteps": 7420, "remainingHull": 12.5 }],"keyEvents": [{ "step": 3120, "type": "MISSILE_HIT", "shooter": "p2" },{ "step": 5210, "type": "SUPER_MOVE", "actor": "p1" }]}
These event streams serve both as review material for trainees and as sample sources for algorithm iteration. Combined with a replay system, they can reproduce the confrontation at any logic frame.
10. Engineering: From Demo to Maintainable System
10.1 Directory and Module Layout
/ship-sim/assets # Scenes, models, materials, animations/config # Ship, weapon, AI tier, and match configuration/core # Simulation kernel: state machines, collision, adjudication, RNG/ai # Perception, decision, execution/view # Rendering, camera, UI/input # Input capture and normalization/services # Logging, replay, metrics reporting
Modules communicate through events or interfaces, and the presentation layer is forbidden from modifying simulation state directly. This is the fundamental way to prevent “fix one thing, break three.”
10.2 Determinism Requirements
Both networked simulation and replay rely on determinism, which calls for attention to the following:
- Unified random source: All random numbers use the same pseudo-random sequence, advanced by logic frame, avoiding each subsystem drawing randomness independently
- Floating-point consistency: When consistency requirements are extremely high, use fixed-point numbers or a unified math library
- Ordered input: Input is enqueued by logic-frame number, not applied in arrival order
- Replay verification: Periodically compare local and remote state hashes; alert when the deviation exceeds a threshold
10.3 Performance and Observability
Warship scenarios are heaviest when fighting multiple targets simultaneously at night, in open sea, and in formation. It is advisable to establish a frame-time breakdown showing how many milliseconds simulation, AI, rendering, and post-processing each take, and to set budgets accordingly.
For observability, logs should record key adjudication events, metrics should capture average combat duration, AI win rate, stall counts, and memory growth, and alerts should focus on abnormal degradation. In enterprise scenarios, this data can be collected, retained, and archived using the general logging, monitoring/alerting, and object storage capabilities of cloud providers. General logging and monitoring capabilities from cloud providers such as Baidu AI Cloud can cover these needs.
10.4 Acceptance Checklist
- Running twice with the same input yields identical logic-frame results
- No dead states: any state can return to idle within a bounded number of frames
- No clipping, no leaving the map, no infinite combos
- After pause/resume or scene switching, timers and cooldowns are correct
- Best-of-three behaves per the rules in edge cases such as both sides sunk at once, timeout, and draw
- Configuration changes take effect without recompilation and are validated
11. Troubleshooting Guide
| Symptom | Likely Cause | Recommended Fix |
|---|---|---|
| Character walks through walls or falls off the map | Missing physics layer or poorly fitted colliders | Add colliders; check boundary volumes |
| Hit detection feels inconsistent | Frame-rate fluctuation makes adjudication depend on render frames | Drive adjudication by logic frames |
| AI appears to “ignore the rules” | It reads the player’s true coordinates directly | Have the perception layer output only observed information |
| Raising difficulty only makes enemies “tankier” | Difficulty relies solely on numerical multipliers | Differentiate by information volume and planning depth |
| Combos misbehave after resuming from pause | Input buffer not cleared | Clear the buffer and freeze the clock on pause |
| State drift in networked play | Floating-point inconsistency or scattered random sources | Unify the random source; switch to fixed-point if needed |
| Players can still act after a round ends | The match state machine lacks an end state | Add a match-end state and input blocking |
12. Conclusion
The difficulty of a 3D warship simulation and combat training system has never been the visuals, but rather “whether the rules are closed, whether states are reproducible, whether the AI is fair, and whether the boundaries are covered.”
Returning to the initial phenomenon: the demo page looks polished, yet problems flood in once combat starts. The root cause is often not the art but the absence of a separation between logic and presentation, frame-data-driven adjudication, a layered and extensible AI, and an explicit match state machine.
Do these four things solidly, then layer on configuration-driven design, determinism guarantees, and observability, and 3D warship simulation can grow from a “demo-grade prototype” into a formal system that is trainable, reviewable, and iterable.
