Since last week’s episode, we’ve put some overtime into testing out auto-filling Project Skyring’s room with the hex tiles we designed. As we like to make everything we do as transparent as possible, here’s what we did.
Our first solution, just to test it, was to brute force fill the entire room with hex tiles. As you can already foresee, with the large room we have, this led to two problems: 1) it took a long time to fill and 2) with all of the hex objects existing at once, the game’s framerate grinded. We knew that wasn’t going to be a solution, but we wanted to check the worst case, so we could understand how much better other cases were when we moved to them.
The first “other case” was the one we tried this week – a random fill based on the player’s location. By dividing the room up into several large chunks, we only had to fill the ones near the player. This made the fill process more or less instant, and, because hex tiles out of view weren’t rendered, it saved on frames as well. It worked well enough to allow us to land and run around on the ground a bit, but it also reminded us that a random fill wasn’t going to get us anywhere near the ideal solution we’d want for islands in the ocean.
Although we could try to tack adjacency rules on to the random tile generator (to avoid mountains dropping off into the sea, etc.), we’ve come up with what we think will be a much better, more organic approach: island seeding. What we’ll try to do next is drop “seed hex tiles” into random spots of the ocean and put those seeds in charge of generating the landforms. This has several advantages to the patched up random solution. One, it’s possible to determine how many islands are in a room. Two, the relative sizes of islands can be defined (as in, we want 3 big islands and 2 small ones in this room).
The Steps for Making the Hex Grid
- a seed hex tile is dropped
- the seed’s relative size and type (mountainous, flat, forested, etc.) is determined
- further hex tiles are dropped in the 6 adjacent directions
- the mutation probabilities of those hex tiles is determined by the rules passed on from the seed hex tile
- the likelihood of another “land” tile as opposed to an ending “ocean” tile rises as further tiles are laid down away from the seed
- eventually, all 6 directions (and the spaces in-between) will end in ocean
- an island is born
That gives us the basic land form, but we still have a decision to make after that regarding obstacles – do we start the island filled with obstacles and clear them to make paths for the player, or do we start out with an empty island and add obstacles?
Adding obstacles is more intuitive, but a little trickier to ensure paths to every place the player needs to go. With the subtractive method, we could at least use something like a Drunkard’s Walk Algorithm to guarantee a path from a landing strip to artifacts or monoliths.
Once that’s solved, we’ll even be able to save these islands out to individual data files if we so chose, so only islands relevant to the player are ever “loaded” into the game.
There’s a lot of work involved, but we’re going to get started on the seeding process this coming episode. Here’s hoping it works out!