Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CPU tactics

crates/engine/src/ai.rs picks moves by distance and dice; crates/engine/src/ai/tactics.rs adds reactions for CPU level 3 and above. Works for native (UMF) and M.U.G.E.N fighters alike, because it only reads commands, the move list and fighter state.

TacticTriggerAction
Anti-airRival airborne, descending (vel.y > 0) and within ~105 unitsPicks a usable command whose motion starts F, D, DF (dragon punch)
Whiff punishRival attacking, no contact yet, state time over 6 ticks, just out of reach (0.8 to 2.0 times the near range)Picks a multi-step (ranged) command
Hit confirmOwn attack connected (move_hit > 0) and control not back yetPicks a multi-step command; the compiler's cancel rules let it connect
Meter disciplineEvery random or reactive pickNeeds power >= cost; EX moves keep one bar in reserve; supers only while the rival is in hit-stun, below 40 % life, or the fighter is below 50 % life

Each reaction fires with probability 0.35 + 0.6 * skill and sets a short cooldown.

Evidence

cargo run --release -p ume-engine --example native_duel (21 fighters, 1260 rounds, level 6, 3 seeds): see docs/evidence/ai-tactics/.

BeforeAfter
Knockout rate83.4 %96.7 %
Average round70.9 s54.5 s
Damage per round13881527
Win-rate spread24.7 pts23.2 pts
Rounds with stuck fighter00

Tests: cargo test --release -p ume-engine --test it ai_tactics:: and the unit tests in ai/tactics.rs.

Reading the rival (ai/reading.rs)

SkillBehaviour
Reaction delayThe CPU only sees an attack after (8 - level) * 2 ticks, so low levels block late and level 8 reads at once
Guard heightBlocks low or high from the attack's guardflag instead of guessing
Block punishRival move was guarded and he is still recovering: answers with a single-input normal (more often at higher levels)
Rival profileMoving averages of how often the rival jumps and guards: jumpy rivals raise the anti-air chance, turtles raise the attack chance

Evidence in docs/evidence/ai-reading/: cargo run --release -p ume-engine --example ai_ladder plays mirror matches between levels (level 8 beats level 3 in 66.7 % to 86.5 % of rounds, level 6 beats 3 in 54.8 % to 81.0 %), and native_duel shows 96.7 % to 99.4 % knockouts with the average round going from 54.5 s to 45.6 s.