ClashRoyaleAi: Open-Source Deterministic Clash Royale Simulator with Integrated RL Capabilities Released
By Mr.Xu
Published:
Summary:ClashRoyaleAi is an open-source, deterministic simulator for the real-time card game Clash Royale, designed to serve as a reinforcement learning (RL) environment. Built on C++17 and compatible with the Gymnasium API, it includes all 132 cards and 41 evolutions as of July 2026. The simulator boasts high performance, running full matches in ~10 ms on a single CPU core, with state snapshots in 7–20 µs for lookahead and A/B testing. It integrates recurrent PPO, curriculum learning, and self-play mec
ClashRoyaleAi: Open-Source Deterministic Clash Royale Simulator Released
Clash Royale is a real-time, two-player, partially observed card game with no official API. To address this, developer itzik123 has rebuilt the game's battle engine as a headless C++17 simulator, making it available as an open-source project. Key features of the simulator include:
- Comprehensive Game Content: Includes all 132 cards and 41 evolutions as of July 2026, and is fully deterministic with support for random seeding.
- High Performance: Runs full matches in ~10 ms on a single CPU core, with state snapshots (
snapshot()) in 7–20 µs, enabling lookahead and A/B testing. - Gymnasium API Compatible: Supports standard reinforcement learning interfaces, with a 13,977-float observation vector that includes the opponent's played-card history.
Technical Highlights
- Reinforcement Learning Framework: Integrates recurrent PPO (CNN + LSTM, 1.85M parameters, CPU only) and employs curriculum learning, where the agent is trained against a teacher that ranks its plays and pilots 16 ladder meta decks.
- Self-Play Mechanism: PFSP (Prioritized Fictitious Self-Play) self-play league enhances the training efficiency of the AI agent.
- Experimental Results: Initial tests show that 1-ply lookahead on the policy increases the win rate from 0.625 to 0.944 (160 paired matches, 95% CI +0.24 to +0.40). Distilling the search back with value-distribution targets and DAgger further improves the win rate by 0.045 (1,600 paired matches, p = 0.007).
Developer Recommendations
Although the agent is not yet strong, the project provides a flexible and efficient platform for reinforcement learning research. Developers can leverage this simulator to train and optimize AI agents, experimenting with advanced algorithms to achieve more powerful strategies.
Future Directions
The project is currently running a from-scratch training session and plans to integrate more advanced reinforcement learning algorithms to enhance the agent's overall performance. Additionally, the developer intends to expand the simulator's capabilities, such as supporting more complex game mechanics and richer observation data.
Conclusion
The release of ClashRoyaleAi provides a valuable tool for Clash Royale AI research and opens new possibilities for the reinforcement learning field.
— END —Source: Reddit r/MachineLearning (2026-09-27)
Tags: #Reinforcement Learning #Open-Source Simulator #Game AI #Clash Royale #PPO Algorithm
Community Comments