RC RANDOM CHAOS

Elden Ring's Boss AI Is Just a Stack of States and Weighted Dice Rolls

· via Hacker News

Original source

The Low-Tech AI of Elden Ring

Hacker News →

FromSoftware’s reputation for brutal, varied enemy encounters rests on a surprisingly simple architecture, as revealed by community efforts to decompile and reverse the game’s Havok Script (a Lua dialect). Rather than anything resembling machine learning, the AI runs on what the studio calls Goals — discrete states organized not as a flat state machine but as a stack, making the system a pushdown automaton. Each frame, an actor updates the topmost Goal, which can push sub-Goals (like a sequence of attacks) onto the stack. Goals return Continue, Success, or Failure; a failure unwinds the stack back to the parent, letting the AI abandon a combo and pick a fresh action.

The actual decision-making lives mostly in each Goal’s ‘activate’ callback, which performs a weighted random selection among candidate action functions. Weights shift dynamically based on context — distance to the target, HP thresholds, animation cooldowns, and per-actor RNG — so a boss far from the player might favor a leap attack while a close-range boss leans on light combos. Composition does the heavy lifting: complex behavior emerges from nesting simple, parameterized building blocks like a generic ApproachTarget Goal.

A second callback, Interrupt, handles reactive behavior. Interrupts bubble up from the executing Goal through its parents until one consumes the event, letting designers script immediate responses — flying into a rage when set on fire, or punishing a player who pauses to drink a flask. It’s the same mechanism behind notorious ‘gotcha’ moments like the Bell Bearing Hunter reacting to spellcasting or item use. The takeaway: memorable, punishing AI comes from careful hand-tuned design, not algorithmic sophistication.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.