Dynamic Difficulty Adjustment (DDA) systems in games traditionally optimize for a target win rate, treating difficulty as a single number to tune up or down. However, challenge alone does not guarantee engagement. Two players can both win at the same rate while having qualitatively different experiences: one narrowly survives a tense battle at 40% health while the other cruises to an easy victory at 95% health. Existing approaches cannot distinguish between these experiences and provide no mechanism for adapting to a player's current state in real time. In training simulation contexts such as those explored by our client Lockheed Martin, disengaged users learn less effectively. This project asks: can a reinforcement learning agent learn to maximize player engagement rather than difficulty, adapting in real time to individual player state?

[Figure 1. Flow Theory: engagement occurs in the narrow band between anxiety (too hard) and boredom (too easy)]
We built a dual-objective reinforcement learning system that serves as an AI Director for an Into the Breach-style tactical roguelike game. The system employs a two-layer hybrid architecture separating strategic decisions from tactical execution.

[Figure 2. System Architecture]
The strategic Director controls enemy spawning decisions: what types to spawn, where, and at what aggression level. Two PPO policies are trained independently with different reward functions. The engagement policy maximizes a composite reward combining flow zone maintenance (player health between 30-70%), close call frequency, mutual combat, and outcome quality. The challenge policy maximizes raw difficulty metrics such as damage to the player and buildings destroyed. A contextual bandit meta-controller classifies the player into one of four states based on health ratio (struggling, challenged, comfortable, dominating) and selects a mixing parameter alpha that blends between the two policies. When the player is struggling the system eases off; when dominating it pushes harder.

[Figure 3. The Contextual Bandit]
The tactical controller operates downstream, converting the Director's pressure decisions into concrete per-enemy movement and attack actions using a search-and-score policy with legal move masking. The scoring function combines local tactical opportunity with the Director's aggression and target priority parameters, producing different enemy behavior on the same board state depending on the strategic context.
Results
The system was evaluated across 12 configurations comparing three memory architectures (MLP, LSTM, GTrXL) and three training objectives (dual, single-engagement, challenge-only). The MLP architecture outperformed recurrent alternatives by 9.2% on engagement and 19.5% on reward while training 2-6x faster, attributable to the game's lack of meta-progression mechanics. The dual-objective configuration achieved the highest engagement score (0.414), outperforming engagement-only by 5.9% and challenge-only by 21.1%, validating that separating challenge from engagement produces better outcomes than either objective alone. Correlation analysis confirmed that the engagement metric is independent of win rate (r = -0.09), demonstrating that engagement and difficulty are distinct dimensions that can be optimized separately.





[Figure 4. Objective Comparison]
The trained model is deployed as a FastAPI inference server for real-time integration with the game engine via REST API. The key takeaway from this project is that engagement and difficulty are fundamentally different optimization targets. Optimizing for difficulty alone produced the lowest engagement scores in our experiments, while the dual-objective architecture that balances both through adaptive blending consistently outperformed either single objective. The engagement metrics we developed (flow zone rate, close call frequency, grit score) provide quantifiable proxies for player experience that can guide AI behavior without requiring continuous human feedback. This separation of challenge from engagement, and the ability to blend them based on player context, offers a principled foundation for DDA systems that extends beyond games into any domain where an adaptive system must keep a human participant both challenged and engaged.