[MOD 0.14.x] Water maze

Topics and discussion about specific mods

[MOD 0.14.x] Water maze

Postby swni » Tue Mar 15, 2016 8:12 am

Type: Mod
Name: Water maze
Description: Changes the distribution of water and land at the start of a new game
License: MIT
Author: swni
Version: 0.0.9
Release: 2016-03-15
Tested-With-Factorio-Version: 0.14.16
Category: Gameplay
Tags: terrain, water, land

See page on mods.factorio.com for information. This information may not be up to date.

Long description
Long description

This mod changes the distribution of land and water at the start of a new game.

A variety of terrain generation algorithms are included in the mod, and they can be fully configured by editing config.lua. By default, the mod generates an infinite maze with path width 32. This mod can also be used to remove all water from the game.

Important Notes
  • To configure the mod, edit the configuration section at the top of config.lua. There are instructions immediately below the configuration section. For more advanced features read the comments in patterns/patterns.lua describing the patterns you are interested in.
  • In most configurations, resources are much rarer and harder to reach than in the vanilla game. It is strongly recommended to turn resource generation WAY up, probably to maximum on size and richness at least. You may also want to turn enemy spawns down.
  • The various maze generators can be computationally heavy when exploring new territory far from the origin. This is most true for maze2, which may cause problems on ultra large maps.
  • Thanks to some deep magic, the mod remembers the settings that it had when you started a new game. If you change settings you can still reload old games and they will continue to generate terrain according to the original settings and ignore the new ones. This allows you to have multiple concurrent games going on with different settings. This also allows multiplayer to work even if different players have different settings active (host's settings dominate). (As of Factorio 0.12.30 this multiplayer feature is no longer true, and there is no way around it. You must manually synchronize the settings of all participants in a multiplayer game.)
  • The map setting for water size does not have a direct effect on the game. The map setting for water does affect the distribution of dry/wet biomes and in particular the amount of trees, neither of which the mod modifies.
  • You can choose between blue and green water!
  • Version changes are likely to be incompatible; I suggest completing any games started with an earlier version of the mod before upgrading.
  • It is very hard and tedious to thoroughly test this mod, especially the saving/loading and multiplayer of each of the many patterns and pattern combinations. Let me know if you encounter any bugs.
  • Mod has been tested on multiplayer.
  • The 'SquaresAndBridges' pattern with a path width of 2 does align with railroad tracks properly.

Unimportant Notes
  • The maze1 generation algorithm guarantees that all landmasses are infinite in size. With probability 1, all land is accessible from the starting location. The algorithm will never generate 2x2 regions of solid land or solid water (other than the origin), making it quite hard to find places to build a factory. The algorithm will sometimes make loops. This algorithm tends to align land in rings centered on the origin. Internally, the algorithm uses the union-find algorithm and also base Fibonacci. This maze generation algorithm was wholly devised by me from scratch.
  • The maze2 generation algorithm guarantees that all land is accessible from the origin and that the landmass is infinite in size. This algorithm makes a sparser maze than the previous, but will never generate a 3x3 region of water. The algorithm infrequently generates 2x2 regions of land, making it quite hard to find places to build a factory. This algorithm likes to make straight paths, making it the most suitable for train networks of the three maze algorithms, and generally makes the nicest looking mazes. Internally, the algorithm builds a diffusion-limited aggregate and is based on Wilson's algorithm for maze generation. The diffusion process is quite slow but a small advective bias towards the origin is used to prevent the algorithm from taking an extremely long time in the worst case.
  • The maze3 generation algorithm simply randomly makes each chunk land or water (the former with 60% probability). The algorithm guarantees that from the starting square you can travel at least 100 chunks north, east, south, and west. Since 60% is above the critical percolation threshold 59.27% for site percolation on a square lattice, it is very likely (but not guaranteed) that the starting landmass is infinite. This algorithm frequently generates loops and inaccessible islands. This algorithm frequently generates large and irregular chunks of land, making it relatively easy to find places to build a factory. The boundary between land and water is almost a fractal (it would be a fractal if the probability of land were exactly the critical threshold, but in that case land masses would not be infinite).


Pictures
Pictures
screenshots

The screenshots show some example terrain generation algorithms possible with this mod; other
variations are possible. See the configuration section at the top of config.lua for more
information.


Version history
Version history
0.0.6: Partial re-write. Moved configuration to config.lua. Added several new patterns, including Spiral and Islandify. Most patterns renamed more sensibly. Total overhaul of saving and loading to address earlier limitations that made it impossible to load a game saved with certain especially complicated patterns.
0.0.5: Removed dependency and fixed the version in info.json
0.0.4: Rewrote islands pattern so that it aligns with railroad tracks in case path width of 2
0.0.3: Bug fix for big_scans in multiplayer
0.0.2: Improved islands pattern, added no water option, added half and quarter plane options, added translate filter
0.0.1: Initial release


Known issues.
  • This mod behaves poorly if enabled before loading a save where this mod was initially disabled (it stops generating water). In future versions I will print an alert to notify the user of this problem if it occurs. Unfortunately I can't print an alert to let the user know if they forgot to enable the mod before loading a save. Alternatively this problem could be solved by just deleting data.lua but this will create minor artifacts in resource generation (including trees / rocks / biters / etc.). Example artifacts
  • As of v 0.12.30, automatic synchronization of configuration files in multiplayer is now impossible. :( You must synchronize your configuration manually. A workaround is to have the host create a new game with the desired configuration, save and close the game, reset your config file to defaults, open the game, and then invite other players to join.
Attachments
water-maze_0.0.8.zip
(17.49 KiB) Downloaded 178 times
water-maze_0.0.7.zip
(17.46 KiB) Downloaded 34 times
water-maze_0.0.6.zip
(14.73 KiB) Downloaded 41 times
water-maze_0.0.5.zip
(12.23 KiB) Downloaded 163 times
water-maze_0.0.4.zip
(12.24 KiB) Downloaded 61 times
water-maze_0.0.3.zip
(12.06 KiB) Downloaded 38 times
water-maze_0.0.2.zip
(12.04 KiB) Downloaded 65 times
water-maze_0.0.1.zip
(11.73 KiB) Downloaded 59 times
Last edited by swni on Fri Oct 28, 2016 7:09 am, edited 13 times in total.
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby theRustyKnife » Thu Mar 17, 2016 5:43 am

Cool idea, I'm tempted to do the islands for my next playthrough.
I have a little question tho... Are the paths the two tiles that rails can be built on? It would be unfortunate if they aren't.
TRK
Check out my mods!
User avatar
theRustyKnife
Fast Inserter
Fast Inserter
 
Posts: 209
Joined: Thu Feb 26, 2015 9:26 pm
Location: Prague, Czech Republic

Re: [MOD 0.12.x] Water maze

Postby swni » Fri Mar 18, 2016 5:04 am

As of v0.0.4, yes the islands pattern with a path width of 2 (which is now configurable) should align with rails. You can use the translate filter to change whether or not it is aligned in case this is not desired (or in case I messed up and it isn't aligned).
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby Marvin » Sat Mar 19, 2016 8:01 pm

HI. love the idea of this mod and had to try out the island pattern. It made for an interesting playthrough. After first trying with relatively small islands I decided to make a new world with increased size so that each island could have a 4 way rail intersection and a station. Ended up using pattern = islands(64, 64, 6), with all resources on very high settings. The idea was to have islands specialized in making different types of items, with trains carrying specific types of resources where they were needed. I added the fluid barrel mod to be able to transport fluids by train. It took quite some time to build, mostly because building trainstations that could handle a lot of different materials but still have a decent throughput was very challenging, also having empty barrels come back properly plus making sure each station could remove coal to load the locomotives (so that i could have a refuling train going to all stations instead of having all trains have to go to a refuling station). Here is the end result:
http://i.imgur.com/3NHbIvk.jpg
Bottom right is the last area I built and the only one featuring any logistics. The 4 way intersections with a single train stop was my early design, but I ended up needing a separate drop off and pick up station for most islands to be able to have a decent throughput.

Thanks for a great mod!
Marvin
Burner Inserter
Burner Inserter
 
Posts: 8
Joined: Fri Feb 26, 2016 1:49 pm

Re: [MOD 0.12.x] Water maze

Postby swni » Sun Mar 20, 2016 4:29 am

That's a very impressive base you have, glad you enjoyed it!
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby mraider94 » Sun Mar 20, 2016 6:22 am

Trying to figure out what to change to get the comb.
mraider94
Burner Inserter
Burner Inserter
 
Posts: 5
Joined: Sun Mar 20, 2016 6:03 am

Re: [MOD 0.12.x] Water maze

Postby swni » Sun Mar 20, 2016 9:22 am

mraider94 wrote:Trying to figure out what to change to get the comb.


After unzipping the zip file, inside the water-maze_0.0.4 directory you should find a file called control.lua. At the top of the file are a lot of comments describing the configuration options available and how to enable them. (I guess if you are using Notepad/Wordpad/etc. it might not be obvious what text is comment and what text is code.) On line 29, the code "pattern = maze2()" defines which pattern is used for the terrain generator. Change that to "pattern = comb()" to get the comb pattern. On line 31, the code "pattern = chunkify(pattern, 32)" determines the thickness of the pattern; change the number 32 to control how thick the branches of the comb is. (The backbone of the comb is three times as thick as the branches are.) Let me know if you have any difficulties.
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby Yinan » Sun Mar 20, 2016 1:00 pm

Two things:

First, you forgot to change the version number in the info.json from 0.0.3 to 0.0.4 which results in an error (at least for me after unzipping the zip into the mods folder).

Secondly, do you actually need it to be version 0.12.26 for the base game?
I changed that to 0.12.20 (which I'm using) and at least the island pattern worked perfectly. Maybe you should lower it to a version that you actually need as a basic minimum to allow people who don't play with the most recent version to play with it.
Yinan
Fast Inserter
Fast Inserter
 
Posts: 125
Joined: Sun Feb 14, 2016 2:40 pm

Re: [MOD 0.12.x] Water maze

Postby swni » Sun Mar 20, 2016 7:16 pm

Thanks for catching these issues. I tried to automate the process as much as possible but this is the second time I've tested different code than I deployed by accident... Anyhow, I removed the requirement of a specific Factorio version (I've still only tested it on 0.12.26 / 0.12.27) and fixed the version in info.json.
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby mraider94 » Mon Mar 21, 2016 2:05 am

I have a general idea of what was a comment and what was a setting, but notepad is shit for coding. Opened it in chrome the other night to see what its supposed to look like, just notepad seemed to have scrambled it or something.

Found this https://repl.it/ and was able to change it. Just one question, changing the thickness, going up make them thicker on thinner?
mraider94
Burner Inserter
Burner Inserter
 
Posts: 5
Joined: Sun Mar 20, 2016 6:03 am

Re: [MOD 0.12.x] Water maze

Postby swni » Mon Mar 21, 2016 2:27 am

mraider94 wrote:I have a general idea of what was a comment and what was a setting, but notepad is shit for coding. Opened it in chrome the other night to see what its supposed to look like, just notepad seemed to have scrambled it or something.

Found this https://repl.it/ and was able to change it. Just one question, changing the thickness, going up make them thicker on thinner?


The number controls how many tiles wide the branches are; so by default they are 32 tiles wide.

I'm not familiar with repl.it, but I would recommend Notepad++ as a drop-in replacement for Notepad. Notepad++ is very similar to Notepad, but has syntax highlighting suitable for use in coding, has many fewer bugs (although in the newest versions of Windows they have done a decent job getting rid of the most irritating Notepad bugs), and has bunches of other features which you can just ignore. (Personally I use vim but that takes time to learn to use.)
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby DonovanHawkins » Mon Mar 21, 2016 5:00 pm

Great mod! I've always wanted to get more interesting water barriers without losing map connectivity, and your mod means I can finally play on island chains like this:

Image.

This is a composition of your islands pattern with your maze2 pattern:
Code: Select all
function islandify(pattern, islandradius, pathlength, pathwidth)
    local pattern_get = pattern.get
    local r = islandradius or 32
    local k = pathlength or 48
    local w = pathwidth or 2
    local n = 2 * r + w + k
    local function get(x, y)
        local pattern_x = math.floor((x + r) / n)
        local pattern_y = math.floor((y + r) / n)
        if not pattern_get(pattern_x, pattern_y) then
          return false
        end
        x = x % n
        y = y % n
        if (x < w and pattern_get(pattern_x, pattern_y + 1)) or (y < w and pattern_get(pattern_x + 1, pattern_y)) then
            return true
        else
            x = (x + r) % n
            y = (y + r) % n
            return (x < 2 * r + w) and (y < 2 * r + w)
        end
    end
    return {get = get, lua = 'islandify(' .. pattern.lua .. ', ' .. r .. ', ' .. k .. ', ' .. w .. ')'}
end

pattern = maze2()

pattern = islandify(pattern, 64, 64, 2)


Your maze2 pattern appears to perform caching, so this should be pretty performant. As a bonus, if you create an identity pattern that always returns true and a delta function pattern that returns true at the origin, you can islandify them to recreate the existing islands/island patterns.

I'm really curious to see what other composition patterns people can come up with.

Donovan
DonovanHawkins
Manual Inserter
Manual Inserter
 
Posts: 3
Joined: Sat Jan 30, 2016 6:02 pm

Re: [MOD 0.12.x] Water maze

Postby Yinan » Mon Mar 21, 2016 6:58 pm

DonovanHawkins wrote:[...]

That is awesome. Now I have to start the game again to use that pattern, as it looks beautiful!
Thanks for the share Donovan :D
Yinan
Fast Inserter
Fast Inserter
 
Posts: 125
Joined: Sun Feb 14, 2016 2:40 pm

Re: [MOD 0.12.x] Water maze

Postby orzelek » Mon Mar 21, 2016 7:15 pm

This one looks intriguing. Might need to figure out how it will work in conjunction with RSO.
Since both use the on_chunk_generated event it might be a bit tricky.

Small proposal - please add a config.lua and move settings there. Then just use them in other lua files. Thats the convention used around here in mods.

(There is a non-0 chance that to work properly I would need to move mode code into RSO - would you be ok with it? Nicely credited in proper places ofc )
orzelek
Smart Inserter
Smart Inserter
 
Posts: 3213
Joined: Fri Apr 03, 2015 10:20 am

Re: [MOD 0.12.x] Water maze

Postby swni » Mon Mar 21, 2016 9:59 pm

Donovan- That looks fantastic, may I have your permission to add your code/ideas to the mod? (with credit of course) (And yes, maze2 caches.)

Incidentally, at first the islands pattern was going to make circular islands, but I thought that was just a bit too cruel.

orzelek- I'll look into moving things to config.lua. I imagine this mod will have no trouble with RSO, assuming RSO doesn't care about land/water. This mod turns off the normal water generation, so the only thing it does during on_chunk_generated is change land tiles to grass, water, or deepwater (or not change them at all), so the only interaction with resources is deleting resources that end up in the water, in which case it shouldn't matter which one is run first. You can copy code if necessary, but maybe using the remote script interface somehow might be better?
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby DonovanHawkins » Mon Mar 21, 2016 10:35 pm

swni: Certainly, feel free to use them.

orzelek: RSO seems to be working well enough with this mod as long as you bump the resources up or are willing to travel a bit further. The only problem was losing starting area resources when the island radius was small, which is also going to be a problem with vanilla resource generation. An island radius of 32 was bad, but 64 worked fine.
DonovanHawkins
Manual Inserter
Manual Inserter
 
Posts: 3
Joined: Sat Jan 30, 2016 6:02 pm

Re: [MOD 0.12.x] Water maze

Postby swni » Mon Mar 21, 2016 10:42 pm

You can also use 'union' with island to make a big area of guaranteed land around the origin, so you don't lose starting resources
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby orzelek » Mon Mar 21, 2016 11:08 pm

swni wrote:Donovan- That looks fantastic, may I have your permission to add your code/ideas to the mod? (with credit of course) (And yes, maze2 caches.)

Incidentally, at first the islands pattern was going to make circular islands, but I thought that was just a bit too cruel.

orzelek- I'll look into moving things to config.lua. I imagine this mod will have no trouble with RSO, assuming RSO doesn't care about land/water. This mod turns off the normal water generation, so the only thing it does during on_chunk_generated is change land tiles to grass, water, or deepwater (or not change them at all), so the only interaction with resources is deleting resources that end up in the water, in which case it shouldn't matter which one is run first. You can copy code if necessary, but maybe using the remote script interface somehow might be better?


The thing is that RSO tries to not place resources in the water and can move them by up to a chunk to spawn them. So order will matter since you might get resources you wouldn't in other case. And with RSO this can be quite important.
Idea with remote interfaces would work maybe. We would need have an interface that one mod would call before/after his work is done.
Mods would need to detect each other presence - it can be done by checking for existance of remote interface.

If you could cehck for RSO's interface to skip chunk work and make remote access to your make_chunk I could sort it out on RSO side to make terrain changes first then proceed with resource generation. I'm not sure how this would function in places where resources cross chunk borders.

I have also alternative idea in mind but would need to verify some things to make sure it's actually doable - remote interface seems easier.
orzelek
Smart Inserter
Smart Inserter
 
Posts: 3213
Joined: Fri Apr 03, 2015 10:20 am

Re: [MOD 0.12.x] Water maze

Postby swni » Mon Mar 21, 2016 11:39 pm

It should be pretty easy for Water Maze to expose two remote interfaces; one that tells it whether to suppress calling make_chunk in response to on_chunk_generated, and another to explicitly call make_chunk when desired. Then RSO can call the former on_init and on_load, and the latter right before its own chunk generation work. This way RSO needs to be aware of this mod, but not vice versa. (Or we could go the other way.) Does that sound good?
swni
Long Handed Inserter
Long Handed Inserter
 
Posts: 69
Joined: Sat Mar 05, 2016 1:54 am

Re: [MOD 0.12.x] Water maze

Postby Yinan » Tue Mar 22, 2016 6:24 am

I'm using water maze together with Train Outposts (which is an RSO derivat) and it works good.
Only Problem I had with my new Map that I haven't seen any Oil Well so far... maybe I have to adjust the cost for the bergius process mod so that I can research it without needing to have plastic first (only problem will be the initial heavy oil but oh well, if worst comes to worst, I'm just gonna summon a heavy oil barrel -.-).
Yinan
Fast Inserter
Fast Inserter
 
Posts: 125
Joined: Sun Feb 14, 2016 2:40 pm

Next

Return to Mods

Who is online

Users browsing this forum: Clinkenweird, ZlovreD and 6 guests