Friday Facts #207 - Lua noise specification

Posted by HanziQ & TOGoS on 2017-09-08, all posts

Hello, it seems the summer heat has finally subsided, and we have not had to run our AC units the whole week. We mentioned earlier we have had Dominik in for a testing week, and we are happy to say that he is quite qualified for a position here, so will be remaining with us. Tom has also joined us, moving here from the Republic of Ireland, and has been getting settled in working through a lot of the small unassigned tasks. It also seems most of us are back from our vacations, so the pace is picking up again.

Most of the work this week has been on the unentertaining spectrum, with a lot of internal reworking and refactoring going on. A lot commits related to fixing our compilation after the move to C++17. Many of the GUI and input action functions were broken (such as rebinding keys, switch map editor tabs, setting combinator filters), so its been a team effort to fix these as they are found. Hopefully not many will slip through the cracks and into release.

Lua noise specification TOGoS

As mentioned in an earlier FFF, one of the planned features for 0.16 is to allow composition of noise functions from Lua code, so that we (and modders) can have more control over how the map is generated. Over the past several weeks I've been getting that working and playing around with it trying to make a world that has a lot of variation as you explore far away, but is not too crazy near the starting area.

Sometimes it can be hard to visualise what effect changing the noise will have on the resulting map. To give a somewhat more intuitive feel to how the 'elevation' of the noise is affected, I added height shading to the preview. While only used in the game to place water, showing it in this way really helps to see the underlying structure of the noise.

One of the problems I've been tackling is how to allow large bodies of water while ensuring that the player never starts on a tiny island. One way to do this is to add in a web-like structure near the starting area. This can be done by taking some medium-frequency noise with a positive bias (to ensure that there are land bridges to everywhere) but folded back down above a certain elevation to add lakes, subtracting distance from the starting area from that, and then taking the maximum of that and the general world elevation noise.

As a simple example, the Lua code to do create such a noise function looks like:

data:extend{
  {
    type = "noise-expression",
    name = "starting-area-webbing",
    expression = noise.define_noise_function( function(x,y,tile,map)
      reset_seed(map.seed)
      local continents = new_basis_noise(x,y,32,1/512)
      local webbing = noise.ridge(new_basis_noise(x,y,16,1/64), -math.huge, 8)
      return noise.max(continents, webbing - tile.tier)
    end)
  }
}  

The result looks like this in the previewer:

Mod portal 2.0 progress HanziQ

Over the summer, we have had a French student Lucien working with us in the office. As a part of his internship, he was helping us develop the new version of the mod portal. It took a long time, as I (Martin) had many other things to work on, and couldn't fully dedicate myself to finishing this long-overdue project, but we are nearing the end. We're hoping to release the new version this month.

Apart from speed and performance improvements, there will probably not be many more changes on release, but we'll start working on new features right away. This new version gives us a much more solid foundation to work from. You can let us know on our Mod portal discussion sub-forum which features/improvements are the most important to you, and there will proobably make a poll later on to see which we should focus on.

As always, let us know what you think on our forum.