Created by Wizard Mode (Ben Porter), MoonQuest is a single-player procedurally-generated adventure game set in a strange nocturnal world. The gameplay is a mix of roguelike and minecraftian genres and sits somewhere between Terraria and Spelunky, with the main aim to search the generated world for moonstones.
MoonQuest was started in 2011 by Ben Porter after leaving his academic research job (where he studied procedural generation). It was originally called Moonman but the name was changed in late 2016 to accommodate the growing cast of characters and change of focus. The game engine was written from scratch and incorporates some open source software such as SFML and Box2D. Each starting character influences the kind of game that is created. For instance, the Amphibian breathes underwater, increases the chance of the Water Moon appearing (which brings rain and flooding), and starts with a fairly strong weapon. By selecting the Human character, on the other hand, the world is guaranteed to have: Silver or Gold ore, a Pale Moon (which generates a protection aura around the player) and adundant treasure. The Human is essentially the “easy mode”. There are other characters which can be unlocked, such as the Crusader, who starts with full armour but generates a world that has more dangerous ruins and no guarantee of abundant minerals.
The game engine is around 120k LOC, written in c++. Ben built supporting scripts in Python, such as the game planner and the engine does everything from displaying animated sprites, simulating water flow, composing the final scene from the various passes (foreground, background, starfield, glow, lighting, refraction, etc), generating region geometry, loading and saving games, controlling creatures, etc. The game planner generates the basic world structure by joining up different regions. There are obstacles and resources in the game, and the planner ensures that the player can always access the resources required to overcome an obstacle. For instance: the player may need a shovel to get through a tough clay deposit, and so the planner will make sure there is enough iron ore and lumber available before the clay seam, so the player can craft the shovel. The game planner is written in Python and directly generates c++ code with the basic game plans. The game engine modifies the basic game plans by adding or removing regions or connections and then adds extra content like trees, minerals, bosses, NPCs, and so on.
The quest in MoonQuest only has a couple of obstacles, but Ben has also experimented with more complex situations. On the right you can see an example of the game planner solving a hypothetical game. The planner walks through the nodes starting from home and tries to reach all nodes. When it reaches the obstacle “letter” in city walls, it decides to solve it by placing “mayor” (which is in it’s solution database) into mayor’s house. The final output is a game plan which is solvable by a player (e.g., they can access the mayor to get the letter and they can find a sword to overcome the monster). Ben will eventually implement these more complex quest dynamics in the future versions of MoonQuest.
The individual regions are generated with a combination of algorithms and hand-made parts. For debugging purposes, the region generator outputs a HTML page with a visualisation of the area. In the image below you can see a section of the forest area. For this region the core land mass is defined with a polygon (with an undulating top to model hills) that is filled in with a generation function. The generation function defines the distribution of blocks in the land mass, and is a complex mix of perlin noise and other functions. There are several steps after this that do everything from placing plants, eroding sections of the world, placing houses, adding treasure chests, simulating water flow, and so on.
Full Credits: Ben Porter (Mostly Everything), Alex McDonald (Art, Design, Testing), G.P. Lackey (Additional Art), Sam Izzo (Additional Programming, Testing), Aliceffekt (Music), Gio Lobato (Music) and Andrew Monte (Sound Design).
Software: Custom game engine written in C++, Mix of algorithms to generate worlds (Noise, Simple Grammars, Simulation), SFML, OpenGL and Box2D.