Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

I brute-forced all 40,320 orders of my puzzle game, and the table became the design doc

Island Evolution is a small order puzzle: you place 8 items on an empty island, and after each placement everything already on the island grows one level. The order you pick decides how far each thing gets. It's built in

Island Evolution is a small order puzzle: you place 8 items on an empty island, and after each placement everything already on the island grows one level. The order you pick decides how far each thing gets. It's built in Godot 4 and runs in the browser.

Eight items means 8! = 40,320 possible orders. That sounds like a lot until you notice a computer can play all of them in a moment. So I did, and the result changed how I balanced the game.

Rules as data, not branches

The first decision was to keep the rules out of the code. Every item, level and condition lives in a JSON file. A tree, for example, goes sprout → sapling when water is at least 1 → big tree at water 2 → forest at water 3.

The engine just reads that file and runs a lookup-driven state machine. Nothing about the 8 specific items is compiled into the logic. Two things followed from that:

  • Rebalancing is a one-line data edit instead of a hunt through conditionals.
  • The rules run outside the game. A run is a function from an order to a final state, so you can simulate every order without rendering a frame.

What 40,320 runs look like

  • 3 orders reach the perfect score of 27.
  • 35 orders (about 0.1%) finish with nothing dead.
  • The most common score by far is 6, reached by 12,180 orders.

That table is the design document. Whenever I changed a rule I re-ran it. If the number of perfect orders had jumped from 3 to 60, I'd know the puzzle had gone soft before anyone played it. Difficulty stops being a feeling and becomes a number that moved or didn't.

It also answers the fairness question. One perfect order in 40,320 would be cruel. Three is tight but findable, and the 35 survivable orders let you see a nearly complete island, which teaches you what to fix.

The hazard bug the table caught

Growth rules are easy to reason about. Hazards weren't. At first the danger check ran only on the turn the dangerous item was placed, so you could place it early and then safely build the thing it was meant to threaten. Now the check runs after every turn against everything on the board. Re-running the 40,320 table after that change rewrote most of the results, which is exactly the kind of thing you want to find out from a script and not from players.

One web-only bug no test would catch

Browsers block audio until the user interacts with the page, so the game unlocks sound on the first click inside the canvas. On the title screen the only clickable thing is PRESS START, and PRESS START leaves the title screen, fading the music out. The unlock and the exit were the same click, so the title theme could never be heard on the web. From the engine's point of view everything worked as designed.

Try it

The game is free in the browser with no account: islandevolution.com. The rules are printed in the evolution chart on the home page, and there's an order solver that uses the same rule table as the game. The longer write-up, including the pixel art pipeline and the audio loudness numbers, is on the original post.

Island Evolution is inspired by Eyezmaze's GROW games, but it isn't an official Eyezmaze game.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.