DEV Community

Surya S S
Surya S S

Posted on AI-assisted

When Game AI Stops Following a Script: The Engineering Behind Adaptive Bosses in Phantom Blade Zero

Tomorrow, Phantom Blade Zero releases, and there's one thing about this game that got me interested beyond the usual graphics, combat, or boss designs.

It's the idea of fighting a boss that can change how it approaches you.

If you've played Soulslike games, you probably know exactly what I'm talking about. The first few attempts against a boss can be brutal. You don't know its attack timings; you dodge too early, miss your parries, and get punished for almost everything.

But after enough attempts, something clicks.

You start recognizing the animations. You know when to dodge, when to parry, and when there's an opening to attack. Eventually, a fight that once seemed impossible becomes manageable because you've figured out how the boss works.

And honestly, that's one of the best parts of these games.

But it also got me thinking: what happens when the boss can change its approach based on how you fight?

That's what made me look deeper into the AI behind Phantom Blade Zero. And the interesting part is that the technology behind this idea is much more worth discussing than simply calling it an AI-powered boss.

So, what actually changes when a boss becomes adaptive?

In many games, bosses operate through carefully designed states and attack sequences. They might have different phases, combos, recovery windows, and reactions, but their behaviour is still governed by rules the developers have designed.

From an engineering perspective, there's nothing wrong with this. In fact, it's a very effective way to build reliable and predictable combat systems.

The problem is what happens after the player learns those rules.

Let's say a boss always finishes a particular combo with a heavy attack. Once you've learned that sequence, you can prepare for the final hit, dodge it, and punish the recovery animation.

You might need several attempts to master the timing, but the underlying sequence hasn't changed.

Now imagine that the boss has other responses available and can choose between them depending on what's happening in the fight. It might interrupt a combo, use a feint, or change its next move instead of repeating the response you were expecting.

Suddenly, learning the boss isn't just about memorizing a sequence. You have to understand the situation and react to the decision it makes.

That's the interesting shift here.

S-GAME, the studio behind Phantom Blade Zero, has discussed using behaviour trees and fighting-game-inspired decision-making for its more challenging encounters. The developers have described bosses that can make more dynamic combat decisions rather than relying entirely on predictable attack sequences.

And that brings us to the technical side.

1. Behaviour trees are more interesting than they sound

When we hear AI, most of us immediately think about neural networks, machine learning, or large language models.

But game AI has been solving decision-making problems for decades, often using much simpler techniques.

One of them is a behaviour tree.

Think of it as a structured way of deciding what an enemy should do next. The system checks the current situation, evaluates which conditions are satisfied, and selects an appropriate behaviour.

For example, a simplified boss AI might consider questions like:

Is the player within attack range?

Is the boss still recovering from its previous move?

Did the last attack connect?

Is the player repeatedly using the same defensive action?

Should the boss attack, reposition, feint, or continue its combo?

These are examples of decisions a system could make, not a verified list of conditions from the game's actual implementation.

The interesting thing is that the boss doesn't need to execute the same sequence every time. It can choose between different actions based on the current state and the rules defined by the developers.

Here's a simplified way of thinking about it:

Observe the current combat situation → Evaluate available actions → Select an eligible response → Execute the action → Observe the new situation → Repeat

The loop is what matters.

The boss acts, the environment changes, and the system evaluates the situation again.

A behaviour tree doesn't automatically make an enemy adaptive, and it doesn't necessarily learn anything. But it gives developers a structured way to create conditional behaviour and combine different combat responses.

When designed well, that alone can make an encounter feel considerably less predictable.

2. But does the boss actually learn how you play?

This is where I think we need to be careful with the terminology. There's a difference between an enemy reacting to you and an enemy learning from you.

Imagine that you keep parrying the final attack of a boss's combo.

A reactive system might detect that you've successfully parried and choose a different follow-up. That's a response to the current situation. A more history-aware system might track how frequently you've been parrying and use that information when choosing its next move. That's closer to player modelling.

A machine-learning system could go further by updating a learned model or policy using observations from your gameplay. But that requires a specific learning mechanism; it doesn't happen automatically just because an enemy's behaviour changes.

This distinction matters when looking at Phantom Blade Zero.

The developers have discussed behaviour trees and dynamic combat decisions, but the public information I've found doesn't establish that the bosses continuously train a machine-learning model on each player's actions.

So I wouldn't describe the system as a boss that necessarily trains itself while you fight.

The more defensible interpretation is that the game uses more sophisticated decision-making to make combat responses less predictable.

And honestly, that is interesting enough without adding claims about machine learning that haven't been established.

3. Here's where the engineering gets interesting

Let's take the parrying example a little further.

Suppose we were designing an enemy that needed to account for player tendencies.

We could maintain a simple estimate of how frequently the player performs certain actions:

How often do they parry?

Do they prefer dodging?

How frequently do they attack immediately after defending?

Do they keep repeating the same response when a particular animation begins?

These are possible features for a hypothetical player-modelling system, not confirmed internal variables from Phantom Blade Zero.

We could represent one of those tendencies using an exponentially weighted moving average:

[p_t=(1-\alpha)p_{t-1}+\alpha z_t]

Here, (z_t) represents the latest observation, (p_t) is the running estimate, and (\alpha) controls how quickly the estimate changes.

Why would this matter?

If the estimate changes too quickly, one unusual action could have too much influence. If it changes too slowly, the system might fail to respond when the player genuinely changes strategy.

That creates a trade-off between responsiveness and stability.

A system could then use the estimated tendency as one input to its decision-making process. If repeated parrying becomes a strong pattern, the enemy might choose to introduce a feint or delay an attack rather than repeatedly offering the same opportunity.

Again, that's one possible implementation, not a claim about the game's source code.

But I find the design problem fascinating. You're not simply making an enemy react faster. You're deciding what information matters, how much history to retain, and how that information should influence its available actions.

And the implementation doesn't even have to involve a neural network.

Sometimes, a well-designed decision system is exactly what the problem needs.

4. Another interesting detail: what happens when an attack misses?

One of the developer discussions around Phantom Blade Zero describes a mechanic associated with the boss Huangxing, referred to as a "lucky draw" state.

The reported explanation is that whether an attack connects can influence what happens next. A successful hit can lead to a continued combo, while a miss can lead to a different response.

I like this example because it shows how much difference can come from making the next action depend on the outcome of the previous one.

Think about a conventional sequence in which a boss always performs the same three attacks.

Now imagine a system where the second attack's outcome affects whether the boss continues the sequence or chooses a different response.

The fight becomes less about waiting for the third attack and more about understanding the situation as it develops.

Technically, this is conditional decision-making based on feedback. It isn't automatically reinforcement learning or online model training.

But it demonstrates an important principle: the outcome of an action can be just as important to the next decision as the action itself.

You see the same general idea in other interactive systems. A robot changes its next movement based on sensor feedback. A workflow changes its next operation depending on whether the previous step succeeded.

The applications are different, but the underlying principle is familiar.

Source: PC Gamer's developer interview on Phantom Blade Zero

5. The difficult part isn't making the boss smarter. It's making it fair.

There's something else I kept coming back to while thinking about this.

If an enemy can choose a response to almost everything you do, does that automatically make it a better opponent?

Not necessarily.

Imagine a boss that counters every attack, reacts instantly to every input, and never gives you an opening. It might be technically challenging, but it wouldn't necessarily be fun.

Players need to understand what went wrong, recognize their mistakes, and feel that a better decision could have changed the outcome.

That means adaptive AI needs constraints.

The enemy's reactions must remain within reasonable timing limits. Its selected actions must be compatible with its current animation and combat state. Its behaviour needs to be consistent enough that players can interpret what's happening, even when they can't predict every move.

And most importantly, the player still needs counterplay.

This is where I think the engineering becomes particularly difficult. The objective isn't to make an opponent that always finds the strongest possible response. It's to make one that can respond intelligently while remaining readable and beatable.

Developers also need to test whether different playstyles remain viable, whether the AI behaves consistently under similar conditions, and whether its decisions can be reproduced and debugged.

Those are not just game-design concerns. They're system-design problems.

A technically sophisticated AI can still produce a poor experience if its decisions feel arbitrary.

6. Why does such a small change have such a big impact?

This is probably the part I find most interesting.

A behaviour tree, a handful of conditional transitions, or a simple player-tendency estimate might not sound particularly revolutionary on its own.

But consider what happens to the player's learning process.

In a conventional encounter, you learn the boss's patterns and build a strategy around them. With enough practice, that strategy becomes increasingly reliable.

When the enemy has more context-dependent responses, the player has to keep evaluating the situation. A strategy that works in one exchange might not be sufficient for the next.

The change affects more than the number of attacks the boss has. It affects how the player learns, how they make decisions, and how much they can rely on previously learned patterns.

That's why the impact can be much larger than the implementation might initially suggest.

The AI doesn't need to invent new attacks or generate new animations. It can change the experience simply by deciding differently about when and how to use the actions already available to it.

Of course, more branches don't automatically mean better AI. Poorly designed variation can make combat random or frustrating. The challenge is to create enough variation to demand adaptation without sacrificing consistency and fairness.

But when that balance works, it changes the entire encounter.

7. The bigger takeaway for AI engineering

I think this is a useful example of something we sometimes overlook when discussing AI.

We tend to focus on the model: how large it is, how much data it uses, or how sophisticated its architecture looks on paper.

But in an interactive system, decision-making matters just as much.

What information does the system observe? What does it remember? How does it evaluate its available actions? How does the result of one action influence the next?

Those questions can matter more to the final experience than whether the system uses a neural network.

A game boss is a particularly visible example because the consequences of its decisions play out directly in front of the player.

But the same design questions appear in simulations, robotics, autonomous workflows, and interactive assistants. In each case, a system becomes more useful when its next action takes the current situation and previous outcomes into account.

That doesn't mean these systems should all use the same architecture. A behaviour tree designed for combat isn't interchangeable with a learned policy for robotics. Their safety requirements, operating environments, and failure costs are very different.

The shared idea is that intelligence in an interactive system isn't just about producing an output. It's about choosing what to do next as the situation changes.

And sometimes, getting that decision right is enough to transform the experience.

Top comments (0)