GAME JOBS
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
August 7, 2013
 
Zindagi Games
Senior Designer
 
Aristocrat
Technical Artist (Visa sponsorship available!)
 
Aristocrat
Tools & Pipeline Programmer (visa sponsorship...
 
Treyarch / Activision
Senior Graphics Engineer
 
XSEED Games
Localization Manager
 
GREE International
Senior Manager of Engineering, Big Data
spacer
Blogs

  Randomly Generating Puzzles in Perfection.
by Greg Lobanov on 08/01/13 10:12:00 am   Featured Blogs
3 comments Share on Twitter Share on Facebook RSS
 
 
The following blog was, unless otherwise noted, independently written by a member of Gamasutra's game development community. The thoughts and opinions expressed here are not necessarily those of Gamasutra or its parent company.

Want to write your own blog post on Gamasutra? It's easy! Click here to get started. Your post could be featured on Gamasutra's home page, right alongside our award-winning articles and news stories.
 

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

howto_1
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

howto_2
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

howto_3
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.

 
 
Comments

Paul Andrew Mcgee
profile image
I feel like this reverse way of achieving a puzzle isn't that uncommon, it's very intuitive. Perhaps more so in toys like Rubik's cubes though.

I do really like your matching method, this might be relevant to something I'm working on.

Marck Ernest Thornton
profile image
Thanks for the info! This actually helps spur ideas I have for some puzzles I'm making in Game Maker as well. Cheers!

Nabi Mortan
profile image
Game Maker is really powerful yet have infinite possibilities to create unique games like yours. Thanks for sharing this.


none
 
Comment:
 




 
UBM Tech