Procedurally Generating Worlds

Welcome to our dev blog! We’re going to try to update this at least a couple of times a week depending on what we’re working on. As CodeSpells revolves around the idea of teaching, we feel that we should be open about the development process and describe what we’re achieving, and more specifically how we’re doing it.

Over the last two weeks, I’ve started working on the procedurally generated worlds for CodeSpells. These are currently relatively small fixed size maps 512m x 512m, with some simple layered aspects of procedural generation. We hope to grow the size substantially but for now, we want to build the general framework for the engine we’ll be using. In most games, the procedural generation would come much later in the development process, but we feel that creating a functioning world with working systems is integral to how we structure the magic you’ll be able to use in the world of CodeSpells.

First off, I am not an expert on procedural generation, and this will not be a super technical write-up, but I want to give a general overview of the topic and what I’ve learned these past weeks.

Screen Shot 2014-09-19 at 10.44.51 AM

Simulating Worlds

One of the most important rules of making games is to cheat wherever possible. Games are intended to create a world that is convincing to the player, but that clearly defines a set of rules and doesn’t break them. Computers have limited power and can’t simulate everything all at once, so you have to focus on what is important to the game. At the same time, you want the player to have freedom, but you can’t simulate everything in the world and make it feel right. Imagine a game where you could control the legs of your character with incredible detail. This could be incredibly fun (see QWOP), but it doesn’t make sense in any game that isn’t specifically about controlling each leg. If your game is about being a fighter pilot, it wouldn’t make any sense to have the legs of the player be simulated in such detail. Moreover, if you never see the pilot, you wouldn’t want to simulate anything relating to the player’s body at all!

For that reason, most video games have static worlds. The mountains, rivers, trees, houses, etc. don’t change, but what you do in it and what happens does. A game like Skyrim basically gives you a world to play in. It’s an incredible world with immense detail, but you don’t have any control over affecting the systems of the natural world. The game reacts to your interactions with other characters in the game and the monsters you battle, because that is what the makers of the game wanted the actual gameplay to revolve around. You don’t worry about burning down trees or digging holes through mountains, and even if the technology of the game supported it, it would take an incredible amount of design work and balance to make it actually be fun.

Something like Minecraft, on the other hand, has a completely dynamic world. The game is about exploring and interacting with the world. Still though, what is simulated is fully designed around what the player will do, and though it does add components of fighting monsters, those mechanics are fairly rudimentary.

What we aim to do with CodeSpells is achieve as much of a dynamic world as possible, so that you can feel the world changing around you. One of our major inspirations is the game From Dust where the entire game is about deforming the terrain to achieve different puzzle-style objectives. The problem with something like From Dust, is that it is hard to scale to larger systems. Something like Minecraft intelligently uses localized changes to update areas that you explore without having to simulate an incredibly large world all at once. When you have a constantly flowing fluid simulation, things get substantially more complicated.

Generating Landscapes

There’s plenty of excellent resources for generating terrain using randomized techniques (see libnoise). We actually use this type of generation, but the only problem with these terrains is that, as much as they can create interesting mountains or hills, they lack the sense of meaning that can be achieved in a natural or handcrafted environment. They don’t achieve the same level of cohesion that you get in real life. In most games, this is resolved with rules for generating the world, or by purely hand crafting the environment. Our current approach is to layer these types of systems together.

First, we create a random terrain, purely from algorithms using noise:Screen Shot 2014-09-19 at 12.55.15 PM

Then we layer sand on top of the terrain to cover it completely and we simulate it settling using Cellular Automata type rules. Note: we still want the sand to settle more than this to fill gaps better and create less clumps.

Screen Shot 2014-09-19 at 12.56.03 PM

And then we can add water at a certain “sea” level:

Screen Shot 2014-09-19 at 12.58.17 PM

And we can continue to add water after that will flow and fill any regions properly.

There’s still plenty of work to do! I have to optimize these systems, and Jason and I are going to make sure to fancy up the look to feel as polished as the rest of the game so far. By next week, we want to clean up issues with the sand not settling properly, cleaning up areas where it looks chunky, etc. But, we feel like we’re on track to creating a pretty convincing world.

With the ability to deform terrain, redirect rivers, and really interact and alter the environment, we want to focus the attention of players on using their magic to interact with a living world so that you feel that your magic isn’t contained to just throwing stuff at other players!

Screen Shot 2014-09-19 at 1.27.41 PM

Screen Shot 2014-09-19 at 11.22.36 AM

Screen Shot 2014-09-19 at 10.49.49 AM Screen Shot 2014-09-19 at 10.47.28 AM

Screen Shot 2014-09-19 at 10.46.30 AM


22 responses

  1. Good day I am so thrilled I found your webpage, I really found you by error, while I was researching on Askjeeve for something else,
    Anyhow I am here now and would just like to say kudos for a marvelous post
    and a all round thrilling blog (I also love the theme/design),
    I don’t have time to read through it all at the minute but
    I have bookmarked it and also added your RSS feeds, so when I have time I will
    be back to read much more, Please do keep up the fantastic work.

    October 7, 2014 at 3:02 pm

    • a_lopezmobilia


      October 7, 2014 at 3:02 pm

  2. Nemo

    Very interesting. Seeing all that water flowing around makes me think of something though. Will there be plans to implement an erosion system? In addition to creating realistic rivers and lakes it would also help to smooth out the terrain.

    September 25, 2014 at 11:25 pm

    • a_lopezmobilia

      Yup, we’re definitely hoping to have the water erode the sand

      September 26, 2014 at 2:50 pm

  3. Hello, I donated $100 for kickstarter, and I have a few questions on how I receive my rewards.

    1: How will you give out the alpha?\
    2: How do we receive the artbook, spellbook, and soundtrack?
    3: How do we get our exclusive wands?
    4: How do we get the invite for the tourney?

    September 23, 2014 at 6:45 am

    • 1. The Alpha Steam key will come to you in the dead of night in an e-mail via Kickstarter. 🙂
      2. You’ll receive these items in an e-mail!
      3. Since we’re deploying CodeSpells through Steam, we’ll be able to associate your staffs to your Steam account!
      4. You’ll receive an e-mail in the dead of night. 🙂

      September 24, 2014 at 3:07 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s