May 2026

Unity Engine · C# · Behavior Tree · Reinforcement Learning · ML-Agents · PPO

RL / BT Comparison Template

A Unity combat-AI sandbox for comparing Behavior Tree and Reinforcement Learning agents in a controlled 1:1 fight.

Project Context

I built a Unity combat-AI sandbox for comparing Behavior Tree and Reinforcement Learning agents in a 1:1 fight.

  • The course assignment required BT/RL strategy design, so I designed the template around a real-time combat loop rather than isolated algorithm demos.
  • The central constraint was fairness: BT and RL agents should differ in decision-making, not in the combat rules they run on.
  • This made the project a controlled testbed for comparing BT decision logic and RL policy behavior inside Unity.

Approach & Implementation

I separated AI decision-making from combat execution, then connected both BT and RL controllers to the same action layer.

  • Built a shared action system where BT agents and RL agents send the same combat commands, and the game logic resolves those commands through cooldowns, hit checks, animation timing, state changes, and episode reset.
  • Implemented attacker and defender BT baselines with condition-action logic: the attacker prioritizes approach and attack timing, while the defender prioritizes blocking, dodging, counterattacks, and distance control.
  • Connected Unity ML-Agents to the same combat loop by defining combat observations, discrete skill actions, reward hooks, and PPO training settings for RL-based strategy learning.
Shared combat execution path
BT baseline logic
ML-Agents training flow

Result

The project makes BT vs RL comparison runnable inside Unity.

  • BT and RL agents can be swapped without changing the scene or combat rules.
  • The setup supports direct comparison between BT strategy and RL policy using win rate, survival time, action distribution, and failure cases.
  • The final artifact connects combat simulation, BT architecture, ML-Agents integration, and PPO training into one runnable Unity project.
BT agent demonstration
RL agent demonstration