Fighting Game Core System Design: From Input Buffer to Match Resolution
This article explains how to structure the core systems of a fighting game, from requirement breakdown and fixed-timestep architecture to character state machines, input buffering, command recognition, hit detection, frame data, combos, defense, throws, quick recovery, and AI difficulty tuning. It focuses on keeping logic and presentation separate, making combat rules data-driven, and designing systems that remain deterministic and responsive under real gameplay conditions.
1. Requirement Breakdown: Converting a Feature List into Executable Modules
A fighting game’s feature list may look scattered, but it can usually be grouped into six capability areas: character and stage presentation, match modes, basic actions, advanced combat mechanics, AI opponents, and flow/results. Before development, each requirement should be mapped to a specific module with clear inputs, outputs, and dependencies. Otherwise, a common problem appears later: every feature works on its own, but they interfere with one another when combined.
Common mappings are shown below.
| Feature Requirement | Corresponding Module | Core Concern |
|---|---|---|
| Character selection, stage switching | Resource and character data layer | Data-driven design; avoid hardcoding character logic |
| Single-player vs. AI, local two-player | Controller and AI layer | Unify input sources as “commands”; decouple from control method |
| Blocking, throws, jumping, dashing | Character state machine | Legal transitions between states |
| Airborne/juggle, combo cancel | Hit detection and frame data system | Hit reaction states and cancel windows |
| Directional special moves, super moves | Input recognition and meter system | Command matching tolerance, resource consumption rules |
| Close-up camera, slow motion | Presentation layer | Separation from logic clock |
| Pause, best-of-three, results | Match flow state machine | Scope of objects frozen during pause |
Non-functional requirements are equally important. Fighting games are highly sensitive to game feel, and input-to-action response latency usually needs to stay within one or two frames. At the same time, the logic update frequency must be stable; otherwise, hit detection may sometimes register and sometimes miss.
2. Overall Architecture: Separating Logic from Presentation
Fighting games typically use fixed-timestep logic updates. The logic layer advances at a fixed frequency, such as 60 logic frames per second, and all hit detection, damage, and state transitions are completed within logic frames. The rendering layer runs independently at the display refresh rate and is responsible only for interpolation and drawing. The benefit is that no matter how machine performance fluctuates, the same input sequence always produces the same result. This is also the foundation for replays and online matches.
A recommended layered structure is as follows:
- Input layer: collect raw keyboard, gamepad, and other inputs, then convert them into unified key events.
- Command layer: convert key events into combinations of direction digits and action buttons, and handle buffering and recognition.
- Logic layer: character state machines, hit detection, damage, and meter resolution, advanced at a fixed timestep.
- Flow layer: round, game, and match state transitions, as well as pause and results.
- Presentation layer: animation, effects, camera, audio, and stage rendering.
The main loop can be sketched as follows:
Each frame (when accumulated real time reaches the fixed step):collect raw inputcommandLayer.process(rawInput) # update input bufferif game is not paused:for each character:controller.generateIntent() # player or AIcharacter.stateMachine.update(intent)hitDetectionSystem.checkCollisionsAndHits()damageAndEnergy.resolve()matchFlowLayer.checkRoundConditions()presentationLayer.renderWithInterpolation(currentState)
Once the presentation layer is separated from the logic layer, slow motion for a close-up camera can change only presentation-layer time scaling while logic hit detection keeps its original pacing. This avoids hit detection misalignment during slow-motion moments.
3. Character State Machine: The Core of Action Legality
The character state machine determines what can be done right now and what state can be transitioned to next. When the state machine is poorly designed, the most common problems are a character suddenly being able to jump during hitstun, or still completing a throw after being interrupted during a throw animation.
3.1 Basic State Partitioning
A playable fighting character usually includes at least the following states:
- Standing, crouching, walking forward, walking backward: movable idle states.
- Jump (takeoff, airborne, landing): a separate set of actions available in the air.
- Dash: forward or back dash, usually with short recovery.
- Block (standing block, crouching block): can only be entered from legal states.
- Attack (normal, special, super): each attack is divided into startup, active, and recovery phases.
- Hit reaction (hitstun, blockstun, airborne): determined by the opponent’s attack.
- Throw and being thrown: both characters’ states must match each other.
- Knockdown and wake-up: determine when the character can act again.
3.2 State Transition Rules
State transitions should be maintained in tables or configuration rather than scattered across conditional checks. A simplified decision logic is shown below:
function canTransition(currentState, targetState, context):if currentState is a hit-reaction state and targetState is an attack state:return false # Cannot attack voluntarily during hitstunif currentState is an attack and is in recovery and targetState is not in the cancel list:return falseif targetState is a super and energy < required super energy:return falseif currentState is airborne and targetState is a throw:return false # Usually cannot throw in the airreturn true
Once rules are configured as data, designers can adjust the cancel list for a state without modifying core code.
3.3 The Three Phases of an Attack
Each attack should be clearly divided into three time segments:
- Startup: from the beginning of the move until hitboxes appear. During this period, the character cannot block the opponent’s attack.
- Active: the period during which hitboxes exist and can damage the opponent.
- Recovery: the recovery time after hitboxes disappear. During this period, the character usually cannot act, making it the opponent’s counterattack window.
The frame counts of these three phases are core parameters for fighting game balance. The frame data system later will expand on this.
4. Input System and Command Recognition
4.1 Unified Direction Representation
The industry commonly uses numpad notation for directions: 5 is neutral, 8 is up, 2 is down, 4 is back, 6 is forward, and the rest are diagonals. This notation is independent of character facing, so it must be converted once using the character’s facing direction. For example, when the character faces right, “6” means forward; when the character faces left, “6” means back. Performing facing conversion in the command layer lets all state machines handle only “forward” and “back,” reducing duplicated logic.
4.2 Input Buffer
There is a time gap between the player pressing a button and the character actually responding, and players’ button timing is often imprecise. The input buffer records inputs from the most recent frames and allows commands to be accepted within a time window. Window length is a game-feel parameter. A common approach is to tune it across several frame values and confirm it with human playtesting.
buffer = ringQueue(capacity = N frames)each frame:buffer.push(currentFrameDirection, currentFrameButtons)function detectCommand(pattern, window):search for each step of the pattern in order within the last window framesif all steps are found, return success
4.3 Recognizing Directional Special Moves
Take a common quarter-circle command such as “down, down-forward, forward plus attack button.” The recognizer needs to do three things:
- Match the direction sequence in order, allowing neutral frames in between.
- Allow each step to be completed within a certain number of frames; restart if timeout occurs.
- The final button press must appear within the same window as the direction sequence to be valid.
commandDefinition = [down, down-forward, forward] + buttonArecognition process:stepIndex = 0traverse historical inputs in the buffer from oldest to newest:if currentDirection == commandDefinition[stepIndex]:stepIndex += 1if stepIndex == commandLength and buttonA is pressed this frame:trigger special moveif timeout:stepIndex = 0
In practice, direction tolerance also needs to account for analog stick values. For example, any tilt beyond a threshold can be treated as the corresponding direction.
4.4 Super Moves and Meter
Super moves usually require a full meter or a specified number of stocks. Meter sources include landing attacks, being hit, and blocking, and the gain from each source needs to be defined separately in configuration. Meter resolution should be completed uniformly after hit detection to avoid the same hit granting meter twice due to ordering.
5. Hit Detection, Frame Data, and Combos
5.1 Types of Collision Boxes
Hit detection systems generally distinguish two types of boxes:
- Attack hitbox: belongs to the attacker and determines whether a hit can land.
- Hurtbox: belongs to the defender and describes the character’s vulnerable area.
When an attack hitbox and a hurtbox overlap, a hit event is generated. The hit event must carry parameters such as damage, hitstun duration, knockback distance, and whether it causes an airborne state.
5.2 Frame Data
Frame data is the core table describing a move. Common fields include:
- Startup frames
- Active frames
- Recovery frames
- Hitstun after hit
- Blockstun after block
- Pushback distance after hit or block
Below is an illustrative data entry. The values are only used to explain the fields and are not parameters from any actual game:
| Move | Startup | Active | Recovery | Hitstun | Blockstun | Type |
|---|---|---|---|---|---|---|
| Example light punch | 5 | 3 | 8 | 14 | 10 | Normal |
| Example heavy punch | 12 | 4 | 18 | 22 | 14 | Normal |
5.3 Combos and Cancels
A combo means that after one attack, the opponent is hit again during hitstun. A cancel means chaining another move during the recovery phase of a move. Common cancel types include:
- Normal cancel: after a normal attack hits, it can be canceled into a designated special move.
- Special cancel: certain moves can be canceled into a jump or dash.
- Super cancel: consumes meter to cancel recovery into a super move.
Combo systems usually also need two limiting rules:
- Damage scaling: within the same combo, subsequent attacks deal progressively less damage to prevent infinite combos.
- Juggle limit: for targets that have already been juggled multiple times, subsequent attacks have weaker or no juggle effect.
function calculateComboDamage(attackList):totalDamage = 0count = 0for attack in attackList:scalingFactor = scalingTable[min(count, maxLevels)]totalDamage += attack.baseDamage * scalingFactorcount += 1return totalDamage
6. Defense, Throws, and Quick Recovery
6.1 Defense
Defense is divided into standing block and crouching block. Standing block can stop most standing attacks and jumping attacks, but cannot stop low attacks. Crouching block is the opposite. While blocking, attacks produce blockstun and may also deal a small amount of chip damage, meaning health lost even while blocking. Chip damage is an important balance parameter and should not be set too high; otherwise, blocking loses meaning.
6.2 Throws
The basic rule for throws is that they cannot be blocked, but they only work when the opponent is in a throwable state. Implementation usually requires:
- Detecting the throw hitbox against the opponent’s throwable range.
- Throws have a separate hit window; they can be invalidated while the opponent is blocking, or a reverse window for “throw break” can be set.
- When both characters initiate a throw at the same time, clear priority rules are needed.
6.3 Quick Recovery
Quick recovery refers to a fast wake-up or roll after knockdown. It is usually available only from specific hit reactions and requires the corresponding button input at the moment of knockdown. Because quick recovery affects combo extension, it should be designed together with the combo system.
7. AI Opponent Design: Implementation Approaches for Three Difficulty Levels
The goal of the AI opponent is not to “aim perfectly,” but to exhibit distinguishable behavior styles at different difficulty levels. Easy difficulty should make the opponent’s hesitation obvious to the player. Hard difficulty should have prediction and pressure ability while still leaving the player room to respond.
7.1 Adjustable Parameters
A mature approach is to split difficulty into several independently adjustable parameters:
- Reaction time: how many frames the opponent needs to respond after observing the player’s action.
- Decision frequency: how often, in frames, to re-evaluate actions.
- Input accuracy: probability of mistakes or tolerance in command recognition.
- Prediction level: whether the AI can block preemptively based on the player’s common behavior.
- Randomness: probability of choosing different actions in similar situations.
An illustrative configuration is shown below. The values are only used to explain the structure:
| Parameter | Easy | Standard | Hard |
|---|---|---|---|
| Reaction time (frames) | 24 | 14 | 8 |
| Decision interval (frames) | 30 | 15 | 6 |
| Input error rate | 15% | 5% | 0% |
| Predictive block probability | 0% | 20% | 50% |
7.2 Decision Methods
Two common approaches are finite state machines and utility scoring. Finite state machines suit clearly structured behavior, such as switching among four modes: approach, poke, attack, and retreat. Utility scoring calculates a score for each available action based on factors such as distance, meter, and opponent state, then selects the highest score or picks randomly by weight.
function chooseAction(situation):candidates = [advance, light attack, block, jump, throw, super]for action in candidates:score[action] = 0if action is in attack range: score[action] += distanceWeightif opponent is starting an attack
