Diamond Realm
A chain-reaction mobile puzzle game: tap a jewel, it bursts and fires shards in four directions. Born in 2015 as Pyro Poppers, brought into our free-to-play production pipeline in 2017, with an algorithm that generates and solves the levels, then updated in 2023.
A grid of jewels, a limited number of taps, and a single question: where do you start? In Diamond Realm, each jewel has up to six hit points. Tapping it removes one; when it has none left, it bursts and fires four shards, up, down, left and right. Every shard that hits another jewel damages it in turn, and one well-placed tap can clear half the board.
The levels are built by an “AI” in the sense of the time: a deterministic algorithm based on a decision tree, with a bit of pseudo-randomness. A far cry from LLMs, big data and today’s AI.
From Pyro Poppers to Diamond Realm
The project started in spring 2015 at Equilibre Games as Pyro Poppers: a first prototype, entrusted to Wladimir Dassonville, then an intern at the studio, then the whole summer to turn it into a complete game, with doors opening on each world, a tutorial, localization, sounds and Google Play Games achievements.
Late 2016, early 2017, we brought the game into our game workflow, with free-to-play mechanics: rewards, unlockable milestones, lives management. Back then, Candy Crush Saga was leading the way. The game also got a new skin and a new name: the firecrackers became jewels and crystals, and Diamond Realm gained a new menu, win and lose animations, shards flying into pieces and a bloom effect on the jewels.
This is one of the project’s successes: Diamond Realm is one of the games that let us assemble all the building blocks of what became Brand Your Game, the industrialization of well-designed video games for our clients.
An art direction that changed the mood
What I remember most is the art direction, chosen by Alisson, in a completely different style from what we were doing at the time: we went from “bro” video games to something more elegant and more feminine. Everyone grew to love it, and it brought a really good mood to the team. I love that!
This change had another effect: to adopt it, we had to decouple the graphics from the code. Diamond Realm thus became a truly reskinnable game, ready to join the catalog offered to our clients.
For a prospect, a well-known ice cream maker, we offered for instance two skins of the same game: the jewels become cones in one, chocolate ice cream bars in the other. My favourite is still the chocolate version.


An algorithm to build the levels
The big task of 2017 was level generation. Instead of drawing every grid by hand, the game builds each level in three steps, we use the BackTracking algorithm.
- A budget. Depending on the player’s current difficulty level, the algorithm randomly picks the grid size (up to 7 by 6 cells) and a total number of hit points to spread across the jewels.
- Chained patterns. A first jewel is placed on a random cell. Then a decision tree made with NodeCanvas picks the next pattern, based on probabilities: a line (from the last jewel, a direction with free cells left, and one or two jewels placed further along that line) or a square of jewels around the starting point. Since shards fly in straight lines, every jewel placed in another’s path creates a possible chain reaction. Placing a jewel on an occupied cell adds one hit point, up to six. This repeats until the budget is spent.
- A solver. The game then replays the grid, shard by shard, trying the possible sequences of taps, up to 15. It starts with the weakest jewels, the ones that most often trigger a chain reaction, and drops any branch that can no longer beat the best solution found. The result is the minimum number of taps that clears the grid.
Finally, the level gives the player that minimum, with a margin that shrinks as the game goes on: half the time, one to three bonus taps before level 15, one or two up to level 30, a single one up to level 50, then none at all: you have to find the perfect solution.
For this solver to run fast enough on mobile, it needed serious optimization: structs instead of classes for the grid, linked lists to add and remove cells constantly, and far fewer allocations to spare the garbage collector.
Besides running the studio and deciding what the project should become, I chose to spend time on this algorithm. Benoit did most of the work on it, and I helped him solve its problems. It wasn’t easy: this is the famous family of “NP-complete” problems. We had to split and bend what we had defined at the start to end up with an algorithm that was optimized yet still fun to play, with a non-linear progression from one level to the next.
Updated in 2023
In November 2023, I picked the project up again to move it from Unity 5.5 to Unity 2021.3, and to replace the old translation system with my open source package Simple Localization, until it built and ran again.