Skip to main content

CPU Opponents

The AFT CPU is data driven, in the style of Street Fighter 6. Each frame, the CPU looks at the situation (neutral, opponent attacking, opponent jumping, punish...), picks one of the tactics written for that situation, and draws a card from that tactic's deck: a move of the fighter, possibly with its combo route, or a movement such as block, walk, dash or jump. Eight levels set how fast it reacts, how well it blocks, how cleanly it inputs its motions and how long its combos are.

  • Designers write the tactics in a CPU Profile data asset, with the CPU Editor, and test them in headless matches without leaving the editor.
  • Generate From Fighter writes a complete first version from the move list of a fighter.
  • Programmers can replace the logic with a Blueprint or C++ brain.

How it runs​

The CPU thinks inside the deterministic simulation, like the rest of the fight. It is rollback, sync test and replay safe, so a CPU side works in every mode, online included.

Each frame, for a CPU team:

perception -> brain -> orders -> executor -> pad inputs -> same command path as a player
  1. Perception: what the CPU sees (distance, heights, health, meter, frame advantage, wall distances, attacks and projectiles coming, opponent state...).
  2. Brain: decides. By default the Deck Brain, which plays the tactics of the profile.
  3. Orders: perform an action, hold a direction, block, wait, dash...
  4. Executor: turns the orders into pad inputs over the next frames, motions and charges included.
  5. The inputs go through the same command recognition as a player: motions, charges, buffers and cancel windows.

The CPU never sets the state of its fighter directly, so its execution mistakes are real input mistakes: a late button or a dropped motion step gives a normal or a jump instead of the special.

CPU Profile​

The AFT CPU Profile asset (UAFTCpuProfile, Content Browser > Add > AFT Fighting) describes how a CPU fights. Double-click it to open the CPU Editor.

PropertyDescription
ParentCommon profile this one extends. A tactic with the same Name replaces the parent tactic; the other tactics are added.
BrainBrain that plays the profile: pick a class, then set its settings (Instance Editable variables of a Blueprint brain). Empty = the parent's brain, else the Deck Brain. See Custom brains.
Override LevelsUse the Levels of this profile. Off: the parent's levels.
LevelsBehavior of the levels 1 (easiest) to 8 (hardest), see Levels.
TacticsThe decks of the profile, see Tactics.
Preview Fighter, Preview Opponent, Designer NotesEditor only: fighter shown on the cards of the CPU Editor and used by its simulation, opponent of the simulation (empty = the preview fighter), free notes.

Reset Levels To Default (Details panel) puts back the default level progression. Generate From Fighter (CPU Editor toolbar) builds tactics from a fighter's move list, see Generate tactics.

Which profile a CPU uses​

The first match wins:

  1. The CPU Profile of the team in the match configuration (Match Tester, FAFTTeamConfig), or of the arcade fight (FAFTArcadeFight): a boss AI for one fight.
  2. The CPU Profile of the fighter (Fighter Data > Simulation | CPU > CPU Profile).
  3. Project Settings > AFT Core > Defaults > Default Cpu Profile.
  4. None: tactics generated at runtime from the fighter's move list (like Generate From Fighter > Complete), with the default levels. A new fighter is playable by the CPU right away.

The level comes from the match: the CPU level of the match options, the CpuLevel of the team or of the arcade fight, the level of the training dummy. See Game Modes.

Template profiles​

AssetContent
/AFT/Data/DA_AFT_CpuCommon11 tactics without fighter moves: movement, defense, wake up and tag team, plus the default levels. The parent of the roster. Generated with Common Only.
/Game/SomndusStudio/AFT/Fighters/Quinn/DA_Quinn_CpuParent DA_AFT_CpuCommon, 9 tactics with Quinn's moves, the parent's levels (Override Levels off). Generated with Fighter Moves Only. Assigned to DA_Quinn.
TacticProfileSituationWhat it does
ApproachCommonNeutralFar from the opponent: get closer.
SpacingCommonNeutralMid or close range when no attack is drawn: footsies.
GuardCommonOpponent AttackingAn attack is coming: block it.
Projectile GuardCommonProjectile IncomingBlock the projectile or jump over it.
Air GuardCommonOpponent JumpingBlock the jump-in when no anti-air is drawn.
Hold GuardCommonUnder PressureKeep guarding when the block stun ends, or get out.
Wake Up GuardCommonWaking UpBlock, backdash or jump away.
Oki ApproachCommonOkizemeThe opponent is down: get close for its wake up.
Advantage HoldCommonAdvantagePlus on block with nothing drawn: stay safe.
Tag OutCommonNeutralTag team, level 3 and up: switch out a hurt point fighter from a safe distance.
Assist CallCommonNeutralTag team, level 4 and up: call an assist at mid range.
PokesQuinnNeutralMid range: long normals, only when they reach.
ZoningQuinnNeutralFar: projectiles.
Close PressureQuinnNeutralClose: fast normals into their combo route, throws.
Jump-InQuinnNeutralIn the air above the opponent: air attack.
Anti-AirQuinnOpponent JumpingHit the jump-in with a move that covers the air.
PunishQuinnPunishThe opponent is recovering: the best route in range.
LinksQuinnComboLevel 4 and up: link a fast move while the opponent is still stunned.
Keep PressureQuinnAdvantagePlus on block: fast normal or throw.
MeatyQuinnOkizemeThe opponent gets up: low, overhead or throw.

Both were generated from the move list with Generate From Fighter (see How the template content was built). Generating again replaces the tactics with the generated names and keeps tactics with other names.

Tuning a generated tactic

Clicking Generate From Fighter again replaces a tactic that keeps its generated name (Pokes, Guard...). Rename a tactic you tune to keep your changes.

To give a new fighter its own CPU, make a child of DA_AFT_CpuCommon and generate its moves: see Create the CPU of a fighter.

Situations​

Each tactic belongs to one situation. The Deck Brain detects the situation every frame.

SituationWhenSeen after the reaction delayChance scaled by
NeutralNothing special happens: spacing, pokes, approach, zoning.NoActivity
Opponent AttackingAn attack of the opponent is in its startup or active frames, close enough to hit.YesDefense
Projectile IncomingA projectile of the opponent is coming toward the CPU.YesDefense
Opponent JumpingThe opponent is in the air and coming in: anti-air or block.YesActivity
PunishThe opponent is recovering from an attack (whiffed or blocked).YesActivity
ComboThe opponent is still in hit stun and the CPU can act: links, juggles.YesActivity
AdvantageThe CPU recovers first, close to the opponent. Only for levels that read the frame advantage, else Neutral.YesActivity
Under PressureThe CPU is in block stun: what to do when it ends. Only for levels that read the frame advantage, else Neutral.NoDefense
OkizemeThe opponent is knocked down or getting up.YesActivity
Waking UpThe CPU is getting up: what to do on its first frame.NoDefense
AnyTried in every situation, after the tactics of the current situation.--

Tactics​

A tactic is a deck of cards for a situation.

FieldDescription
NameUnique in the profile. A child profile replaces the parent tactic of the same name.
SituationWhen the tactic can be played.
ConditionsAll must pass for the tactic to be available, see below.
PriorityThe tactics of a situation are tried from the highest priority.
ChanceChance (%) to play the tactic when it is tried, scaled by the level Activity (or Defense in a defense situation).
Min Level, Max LevelLevels that use the tactic.
EnabledOff: the tactic is ignored (handy to test without it).
CardsThe possible plays, see Cards.
DescriptionFree text, shown in the CPU Editor.

Conditions​

A condition passes when Min <= value <= Max (flags: when true). Invert makes it pass when the test fails.

TypeValue
DistanceHorizontal distance to the opponent (cm).
Height DifferenceHeight of the opponent above the CPU (cm, negative below).
Own Health %, Opponent Health %, Own Meter %Percentages.
Frame AdvantageFrames the CPU recovers before the opponent (negative: after).
Own Distance To Wall, Opponent Distance To WallDistance between the fighter and the stage edge behind it (cm).
Round Time Left (s)Seconds left in the round (999 when the timer is off).
PressurePressure felt by the CPU, 0 to 100 (low health, cornered, blocking).
Partners AvailableTag team partners that can come in.
Opponent Airborne, Opponent Crouching, Own AirborneFlags.
CustomEvaluated by the brain with its Custom Name, see Custom conditions.

Cards​

TypeWhat the CPU does
ActionInputs the command of a fighter action (motion included, with the level execution).
BlockGuards for a while. Guard: Auto (the height the opponent's attack requires, read right with the level Guard Accuracy), High (standing) or Low (crouching).
Walk Forward, Walk Backward, Crouch, WaitHolds the direction (or nothing) for a while.
Dash Forward, BackdashDash input.
Jump Forward, Jump Neutral, Jump BackwardJump input.
Tag, AssistTag team: switch to the next partner, call an assist.
FieldDescription
ActionAction cards: the action to perform. It must be in the fighter's move list: the CPU inputs its command.
Follow UpsAction cards: the combo route, actions performed one after the other when the previous one connects (cancels, target combos, links). The level Max Combo Length caps how many the CPU performs.
Follow Up On BlockAlso follow the route when the previous action is blocked (block strings). Off: only on hit (hit confirm).
Require RangeOnly drawn when the action can reach the opponent (hitbox or throw reach; projectiles reach the full screen). On by default.
Min Frames, Max FramesTimed cards (walk, crouch, jump, block, wait): random duration between the two.
WeightRelative chance to be drawn among the playable cards of the tactic.
Min LevelLowest level that plays the card (generated specials start at level 3, supers at level 5).
Key CardSignature play of the fighter: its weight doubles from level 4 and triples from level 7.
Greyed out fields

The fields that do not apply to a card or condition type are greyed out, not hidden: the Unreal Engine 5.8 details panel can crash with conditionally hidden fields inside array elements.

How the CPU decides​

  1. The Deck Brain detects the situation every frame.
  2. Reactive situations (Opponent Attacking, Projectile Incoming, Opponent Jumping, Punish, Combo, Advantage, Okizeme) are only seen after the level's Reaction Frames, and each occurrence is played once. Until then, the CPU plays Neutral.
  3. A block card and a combo route in progress continue on their own. Movement and waits stop when a new threat or opening is seen.
  4. In Neutral, the CPU waits Decision Cooldown frames between two decisions.
  5. The tactics of the situation are tried by priority: level range, conditions, then a roll of Chance scaled by the level Activity (or Defense in a defense situation).
  6. A card is drawn by weight among the cards the CPU can play right now (level, in range, enough meter, right stance), with the key card bonus.
  7. When nothing is played, the tactics of Any are tried. If still nothing, the CPU decides again after half the cooldown.
  8. For an action card, the CPU inputs the command with the level Execution. When the action connects (or is blocked, with Follow Up On Block), it continues the combo route, up to Max Combo Length follow-ups.

While it waits (Wait cards and between two decisions), the CPU may hold down-back when the opponent can reach it, with the level's Guard Instinct chance. Fast normals cannot be blocked on reaction: this is what blocks them.

Levels​

Each profile has 8 levels (or inherits them from its parent). The defaults follow a Street Fighter 6 like progression; edit them in the Profile & Levels tab of the CPU Editor, or click Reset Levels To Default.

SettingL1L2L3L4L5L6L7L8
Reaction Frames403226211714119
Decision Cooldown3024181411864
Activity %5565758595105115125
Defense %1525405570808896
Guard Accuracy %3040556575859298
Guard Instinct %010254055706590
Execution %5565758290958598
Pressure Mistakes %302825201512305
Max Combo Length00112234
Reads Frame Advantagenononoyesyesyesyesyes
SettingEffect
Reaction FramesFrames before the CPU reacts to a new situation (attack startup, jump, whiff, knockdown...).
Decision CooldownFrames between two decisions in neutral.
ActivityScales the chance of the offensive tactics (100 = as authored).
DefenseScales the chance of the defense tactics (Opponent Attacking, Projectile Incoming, Under Pressure, Waking Up).
Guard AccuracyChance to read the guard height right on Auto block cards.
Guard InstinctChance to hold down-back instead of standing idle when the opponent can reach the CPU.
ExecutionChance to input a motion or charge command right. A missed input comes out late: a normal or a jump instead.
Pressure MistakesExtra missed inputs at full pressure (low health, cornered, blocking): the CPU chokes.
Max Combo LengthFollow-ups of a combo route the CPU performs (0: single hits).
Reads Frame AdvantageSees the Advantage and Under Pressure situations (else they count as Neutral).
  • Level 1 uses no specials: the generated special cards start at level 3.
  • Level 7 has strong tactics but chokes under pressure on purpose (low execution, many pressure mistakes), as in Street Fighter 6.

Debugging​

  • The CPU Editor simulation plays headless matches and lists every decision.
  • In C++, FAFTBattleSimulation::SetCpuDebugSink receives one FAFTCpuDecisionReport per decision: frame, team, situation, tactic, card, action, follow-up step and whether the input was missed on purpose.
  • The AFT.Core.Cpu and AFT.Editor.Cpu automation tests check the determinism, the levels, custom brains, the simulation and the editor.