Perfection. is sort of technically interesting, since it has randomly-generated puzzles. For those who may be unfamiliar, the puzzles take the form of polygons you can cut in straight lines and a shape you're trying to match the polygon to.
I've had lots of people ask me about what goes on under the hood, enough that I decided to just make a brief little post about the interesting parts of it. I'm not actually a good programmer (Perfection. was made in Game Maker, y'know) but I'm hoping some of the techniques here are informative to others or inspire some interesting game designs! Also, I got to have fun making explainer GIFs.
Step One: Generate a Shape
The game picks a number of sides for the shape; when you start out the range is around 4-6, but as you clear shapes this eventually grows to 10-15. Then it just goes in a circle, creating points at a random distance from the center (with some extra rules about staying at about the same distance of te surrounding points). A shape is born! This is saved as the starting shape for the puzzle.
Step Two: Cut It Up
Then the game just plays itself in fast motion, basically, sticking to its own rules and making a goal shape that the player can make. There's a rule that every shape centers itself on the screen, which is what makes the game actually a puzzle and not just a matter of tracing the lines. To pick cut locations, it picks a point at a random angle and in a random range of distance from the center, then makes a line through that point and cuts it there. For puzzles that take more cuts, it just does this more times. For shapes that require rotation and scaling, it rotates and scales the goal. It's that easy! :o
Bonus: Detecting the Similarity
This is another thing people wonder about. Basically, the game breaks each shape into a grid of 0s and 1s--0 means it does not exist there, 1 means it does exist there. Then it puts those grids on top of each other. Anywhere where one shape exists and one does not, that counts as a difference. Anywhere where both shapes exist, that is a similarity. The surface area of difference divided by the combined surface area of the overlapped shapes is the percentage of difference--the game gives you a win when this is at or under around 12%. It's not *completely* binary; edge boxes in the "difference" shape are treated as only "half" a difference, so the game is a bit more forgiving.
I haven't seen another game that works structurally like this, but I feel there's a lot to explore here. When your game works within a system of mechanics the way Perfection. does, techniques like this can be used to generate puzzles forever. In this game I start with the starting point and then create alterations for the player to replicate; for other games, it could go the other way, starting with a goal and then creating alterations the player has to reverse engineer. When the rules are interesting and predictable, the puzzles will be interesting, too.