Core Fighting Game System Design: Input, Combos, and AI Combat Practices
This article explores the core system design of fighting games, detailing requirement analysis, finite state machines (FSM) for character behavior, and input systems including motion matching and buffering. It covers combat mechanics such as blocking, throws, combo cancels, and energy systems, alongside AI difficulty scaling, local multiplayer setups, pause logic, and testing methodologies to ensure balanced and responsive gameplay.
1. Requirement Breakdown and System Boundaries
Fighting games may seem like simple one-on-one combat, but they actually consist of multiple subsystems: input recognition, frame-level state transitions, collision detection, resource management, AI decision-making, and match flow. Before development begins, the scope must be clearly defined to avoid major reworks later.
Common functional scopes can be divided into three layers:
- Core Combat Layer: Movement, normal attacks, blocking, throws, jumping, dashing, airborne states, and combo cancels.
- Presentation Layer: Character animations, cinematic cameras for special and super moves, visual effects, and audio feedback.
- Flow Layer: Single-player mode, local versus, round-based win/loss logic, pause, and match settlement.
The core combat layer dictates the game feel and has the highest priority. The presentation layer can be gradually refined in later stages. The flow layer involves foundational data structures and must be defined early in development.
2. Character State Machine Design
Character behavior should be managed uniformly by a Finite State Machine (FSM). Each action corresponds to a state, and transitions between states are governed by explicit conditions. If a massive number of conditional statements are stacked together, the logic will quickly spiral out of control as characters and moves increase, making validation extremely difficult.
States typically fall into four categories:
- Ground Idle: Idle, walking, crouching.
- Attacking: Normal attacks, special moves, super moves.
- Hit & Stun: Hitstun, blockstun, thrown, airborne.
- Special Actions: Blocking, jumping, dashing.
State transition rules should be written in data files rather than scattered throughout the code. Below is a schematic state transition table:
# Schematic: keys are current states, values are sets of allowed target statesTRANSITIONS = {"idle": {"walk", "crouch", "jump", "attack", "block", "dash"},"walk": {"idle", "jump", "attack", "block", "dash"},"attack": {"idle", "hitstun", "blockstun"},"hitstun": {"idle", "airborne"},"airborne": {"landing"},"landing": {"idle"},}def can_transition(current: str, target: str) -> bool:return target in TRANSITIONS.get(current, set())
The benefit of this approach is that designers can adjust character rules without modifying the main logic, and testers can directly verify which paths are legal.
3. Input System: Directional Commands and Buffering
The responsiveness of a fighting game relies heavily on its input system. Players press a sequence of buttons, and the system must parse them into specific commands.
3.1 Directional Command Parsing
Motion inputs for specials typically use “quarter-circle,” “half-circle,” or similar sequences, such as “down, down-forward, forward plus attack.” During implementation, the directional input for each frame can be recorded, and the target sequence can be matched within a specific time window.
# Schematic: match directional sequence within recent framesdef match_motion(history, pattern, window=12):"""history: list of recent directional inputs; pattern: target command sequence"""recent = history[-window:]idx = 0for step in recent:if step == pattern[idx]:idx += 1if idx == len(pattern):return Truereturn FalseQCF_ATTACK = ["down", "down_forward", "forward", "attack"]
In a real system, two additional issues must be handled. First is directional mirroring: when a character faces left or right, “forward” and “back” must be flipped accordingly. Second is fault tolerance: the detection range for diagonal inputs should be slightly wider, otherwise players will feel that inputs frequently drop.
3.2 Input Buffering
Commands pressed by the player before the current action is completed should be retained for a short period and automatically executed once the character becomes actionable. This mechanism is called input buffering. The buffer window is generally measured in frames, commonly ranging from a few to a dozen frames, with exact values requiring playtesting. Too short a buffer makes controls feel sluggish, while too long leads to misfires.
4. Combat Rules: Blocking, Throws, and Combos
4.1 Blocking and Frame Advantage
Blocking is divided into standing block and crouching block. Their effectiveness against high and low attacks differs, so the hit height of each attack must be clearly defined during design. Blocked attacks cause blockstun, and the difference in recovery time (frame advantage) between the attacker and the defender determines who can act first. This difference is the core data for fighting game pacing and should be listed separately in design documents.
4.2 Throws
Throws usually cannot be blocked by standard defense but require close proximity to succeed. To maintain offensive and defensive balance, throws generally have the following constraints:
- Both characters must be within contact distance.
- Throws can be tech’d (reversed) during the first few startup frames of an opponent’s attack.
- A whiffed throw leaves the attacker in a lengthy recovery state.
4.3 Jumping, Dashing, and Airborne States
Jumping and dashing are the primary means of changing spatial positioning. Jump attacks usually have their hitboxes active in the air and require recovery time upon landing. Dashes can be split into forward dashes and backdashes, with their travel distance, invincibility frames, and recovery times configured separately.
Airborne refers to the state where a character is launched into the air and cannot act freely. While airborne, the attacker can chain additional attacks to form combos.
4.4 Combos and Cancels
A combo is a sequence of attacks chained together while the opponent is in hitstun. A cancel is the act of prematurely transitioning into another action after specific frames of a move. For example, upon a normal attack hit, the move can be canceled into a special move within a limited window, creating a longer combo.
The combo system must handle damage scaling, otherwise extended combos will break game balance. A common practice is to progressively reduce the damage of each subsequent hit within the same combo and limit the number of times the same move can connect.
5. Specials, Super Specials, and Cinematic Cameras
5.1 Energy System
Energy is typically accumulated by landing attacks, getting hit, or blocking. Once the energy reaches its cap, the character can unleash a super special. The energy gain rate directly affects match pacing and should be managed centrally via parameter tables for easy post-launch tuning.
5.2 Cinematic Cameras
When a super special is activated, a common practice is to switch to a cinematic camera and pause regular logic for both characters. Two things must be noted during implementation. First, inputs during the cinematic should be ignored or buffered to prevent player misoperations. Second, camera switching should not affect the combat timeline, otherwise visual feedback and hit detection will become desynchronized.
6. Single-Player and AI Difficulty Grading
Single-player mode requires an AI capable of making decisions. Difficulty differences should not be achieved merely by increasing damage, but should be reflected in reaction speed, input accuracy, and strategy complexity.
Below is a schematic difficulty configuration:
# Schematic: differentiate difficulty via reaction delay, input error rate, and strategy depthAI_DIFFICULTY = {"easy": {"reaction_frames": 30, "error_rate": 0.25, "strategy": "random_weighted"},"normal": {"reaction_frames": 18, "error_rate": 0.10, "strategy": "pattern_based"},"hard": {"reaction_frames": 8, "error_rate": 0.02, "strategy": "adaptive"},}
Easy difficulty might occasionally ignore defense and execute moves with a slower rhythm. Normal difficulty reacts to common player behaviors, such as using anti-air moves when the player jumps frequently. Hard difficulty adjusts its strategy based on match history—for example, recording the player’s frequent combo strings and interrupting them at the right moment.
AI decision-making is usually divided into two layers: the strategic layer decides whether to attack, defend, or create distance, while the tactical layer handles specific move execution and timing. Separating these layers allows testers to inspect the behavior of each layer independently during debugging.
7. Local Versus and Best-of-Three
7.1 Input Mapping
Local versus requires separate key mappings for two players. A common issue is hardware conflict—for instance, when two players share the same keyboard area, key overlaps occur. The design should allow players to customize their mappings and display conflict warnings in the UI.
7.2 Best-of-Three
Match outcomes are calculated by rounds. The first player to win two rounds wins the match, with a maximum of three rounds. Below is a schematic round judgment logic:
def match_winner(round_results, rounds_to_win=2):"""round_results: list of round winners, e.g., ["p1", "p2", "p1"]"""wins = {"p1": 0, "p2": 0}for winner in round_results:wins[winner] += 1if wins[winner] == rounds_to_win:return winnerreturn None # Match not yet finished
After a round ends, the system should record data such as time, damage dealt, and combo counts for the settlement screen and subsequent balance adjustments.
8. Pause and Match Settlement
The key to the pause function is the fixed timestep. Game logic should advance at a fixed frame rate; when paused, logic frames stop advancing, but the UI continues to refresh. If pausing only stops rendering while logic continues to run, input buffers and cooldowns will be incorrectly consumed.
The settlement screen should display the reason for the round’s outcome, such as health depletion or timeout, and show the round score. Win/loss conditions must be checked centrally in the code to prevent inconsistencies arising from multiple modules handling them independently.
9. Testing and Performance Points
Testing fighting games focuses on the precision of hit detection. The following methods are recommended:
- Frame Data Tables: Record startup frames, active frames, recovery frames, frame advantage, and invincibility frames for each move, and perform automated comparisons against actual code values.
- Input Recording and Replay: Save player input sequences to reproduce bugs. Deterministic logic ensures consistent replay results.
- Automated Battles: Have two AIs fight extensively in headless mode to collect win rates and average combo lengths, identifying obviously overpowered characters or moves.
Regarding performance, a fixed timestep helps keep logic consistent across different devices. Rendering and logic should be decoupled; cinematic cameras and particle effects should not slow down hit detection calculations.
10. Summary
The development challenges of fighting games are concentrated in three areas: input, state, and hit detection. Organizing character behavior with a state machine, handling inputs via buffering and motion parsing, managing combat values via parameter tables, and verifying balance through replays and automated battles can keep the system clear and maintainable even as features expand.
