When we demo Lost Sea, one of the things that really grabs people's attention is the fact that all of the islands are procedurally generated. We get a lot of questions about how exactly we build the islands, so I wanted to put together a post that describes the process. It's worth noting that this will be a high level overview, only because I could write ten posts about and still not have covered everything in complete detail!
Procedural Generation was something that we decided to implement right from the very beginning of the project. There were a number of reasons for this, but the primary motivation was that as a small team it would solve a lot of potential issues with content generation. Typically, procedural generation means more work up front but you reap the rewards on the back end. This meant that we would be able to build a bunch of components and, theoretically, get almost infinite content out!
Technical benefits aside, as we solidified the vision for Lost Sea, the randomised terrain and populated islands seemed to really suit the theme of a constantly shifting island chain inside the Bermuda Triangle.
As we had defined the camera angle and core gameplay, we knew that the standard approach of using grey scale noise map wasn't going to work for our terrain. Instead we were going to need something a bit more constrained to side-step any potential camera and navigation issues. We needed to ensure a degree of consistency in the terrain so we could guarantee the player would never be blocked from progressing and minimise any potential issues when the player interacted with objects in the game world.
The solution came in the form of old dungeon crawler board games like Warhammer Quest. In these games the dungeons are built by combining a variety of prefabricated room tiles. Inside each room the key components like door positions and layout are pre-defined but the content inside such as enemies and loot is randomised. This seemed to be a good compromise... lots of variety but consistent quality!
At this point it's important to call out the fact that we use hexagonal rooms as opposed to the standard squares. Hexagonal tiles lend themselves to a more organic shape for the island layout, but more importantly it results in a much higher number of room tile types.
As you can see, square rooms have a maximum of 5 unique room types, as opposed to 13 for hexagonal rooms. After creating a few prototype maps on paper it quickly became obvious that hexagon rooms created significantly more junction points, meaning more player choice in how to navigate the islands.
While hexagonal rooms made the game feel more organic and exploratory, it also caused a number of unforeseen technical challenges that needed to be overcome. For example, some typically very simple tasks such as tiling floor textures and uniform door sizes / positions turned out to be significantly trickier with hexagonal rooms than traditional square rooms.
So with all the building blocks figured out, it was time to move onto the island generation algorithm. Islands in Lost Sea are built in the following order:
1. Define Island Size
Each island is created from a certain number of rooms. This number scales as the player progresses, so islands in the jungle won't be as big as those in the final zone. Each zone has its own special rooms that appear with varying frequency.
2. Difficulty Modifier
When an island is generated, it is assigned a difficulty. Difficulty affects a number of variables, for example - hard islands are much larger, spawn many more enemies, but have fewer tablets, crew and loot available for the player to collect.
The island is then separated into different regions. Random walls are degraded between regions to create multiple branching paths throughout the island. Rooms come pre-loaded with collision and nav mesh information so it doesn't need to be generated during island creation.
4. Beach Caps
Once the island is built, beach caps are added to the exterior of the island to create a smooth transition between the land and the sea.
5. Create Critical Path
An invisible path is drawn from a randomly selected exterior edge to the furthest point on the island, populating it with essential objects such as the dock, tablet locations and special room locations.
An algorithm works to make sure important areas are blocked off from the player by doors. Key are then spawned within a certain proximity to the door to ensure the player can progress without getting too side-tracked.
7. Populate Island
With the island created, it is then populated by crew and critters based on the difficulty of the island. At this stage individual spawners in each room create breakable objects such as bushes, crates, barrels, etc.
When the core island is built, it is then filled with randomised trees, plants and other decorative items based on the biome. Finally, a biome specific texture is applied to the island, so sand for the desert and so on.
Hopefully that should give you a good idea of how we generate the islands for Lost Sea. If you have any more in-depth questions, feel free to send us a message on twitter @lostseagame or leave a comment below.