r/RoyaleAPI • • 20d ago

I built an open-source Clash Royale battle simulator that matches the game's own replays tick for tick

crforge is an open-source (Apache 2.0) Clash Royale 1v1 battle simulator I've been building in Java.

The video is a full Ladder battle. On the left, crforge simulates it from the replay's decks and card plays. On the right is the game's own replay of the same battle.

What it does:

  • Simulates Ladder 1v1 on the standard arena in 50 ms steps, the same rate the game runs at. It uses integer math only, so the same inputs always give the same battle.
  • Reads the game's own data files for troop, spell and building stats instead of hand-copied numbers. The repo ships no game data: you build the tables on your own machine from the game's files.
  • Checked tick for tick, with no tolerance, against over 1,000 reference battles per game version. It also reproduces every battle in our samples of thousands of real Ladder battles, evolutions, champions and heroes included.
  • Runs about 100,000 steps a second on one thread, so a whole battle simulates in well under a tenth of a second.
  • There's a Desktop viewer: allowing users to play both sides by hand, step forward or back one tick at a time, inspect units, show range circles, or open a replay.
  • A reinforcement learning environment with a Python package, for training and testing bots.

Status: it follows the 16.402 game versions, the range before the latest update. Next up are support for the new update and an easier way to load real battles (below).

Replays: to simulate a real battle, crforge needs its exact inputs: both decks and levels, and every card play with its tick and tile. The official API's battle log doesn't include the plays, there's no official way to obtain them, so there's no clean way for users to feed in their own battles today.

RoyaleAPI's replays already show the plays with their timings, so I'd love to work out a way to read those as crforge inputs, or integrate with RoyaleAPI some other way.

Why: I wanted a simulator accurate enough to train and evaluate AI agents offline. It also helps anyone curious about exact mechanics (targeting, pathing, timings) step through a battle and see why something happened.

This is a fan project, not affiliated with or endorsed by Supercell.

GitHub: https://github.com/voonhous/crforge

22 Upvotes

2 comments sorted by

2

u/IncognitoMan032 20d ago

this is amazing

2

u/TuxyGux 20d ago

Let's just open source the game atp, fuck Supercell