Page 1 of 1

Resources spawning on tiny islands in/around water

Posted: Sun Oct 22, 2017 9:53 pm
by DarkMatterMatt
I was having the issue with resources spawning on water (viewtopic.php?t=52937). Updating RSO fixed this.

Now I have a slightly different issue, resources no-longer spawn on water, but they do spawn on tiny islands in the middle of water (see image). The islands are not big enough to have a drill on. It would be nice if a) the resources didn't spawn in disconnected patches or b) the resources only spawned on islands 4x4 or larger (big enough for a 3x3 drill + underground belt off the island)

Image

Re: Resources spawning on tiny islands in/around water

Posted: Mon Oct 23, 2017 7:40 pm
by orzelek
I'd say that having few landfills handy would be helpful :D Ore is spawned in every location it calculated where game says it's allowed.

It would be a lot of checking to analyse the whole patch to remove those small patches. I don't think it's worth implementing especially since landfill is in base game now. It's actually more visible for you since you seem to have very big ore patches - slowdown to analyse the patch could become pretty significant.

Re: Resources spawning on tiny islands in/around water

Posted: Mon Nov 27, 2017 1:06 pm
by mrvn
Should there be ore on the beach though? Looks bad.

Re: Resources spawning on tiny islands in/around water

Posted: Mon Nov 27, 2017 6:40 pm
by orzelek
mrvn wrote:Should there be ore on the beach though? Looks bad.
It's not really question of the looks. It's more of 100's of tiles times 8 checks per tile = real ouchie on performance. And after figuring out direct neighbours you might need to continue further with same tile by going around in larger area to see if it's a 3 tile island or not. Amount of checks required will get really high - even considering that whole ore patch is stored in 2 dimensional table while generating.

It could be made optional - adding second pass after placability check is not that difficult. Figuring out good rules to detect small isles might need some nice algorithm.

I'm not really keen on making any new improvements till v16 of Factorio is around - especially that Rseding91 mentioned somewhere that ability to make sparser ore fields is on his fix list for map gen.

Re: Resources spawning on tiny islands in/around water

Posted: Tue Nov 28, 2017 10:22 am
by mrvn
orzelek wrote:
mrvn wrote:Should there be ore on the beach though? Looks bad.
It's not really question of the looks. It's more of 100's of tiles times 8 checks per tile = real ouchie on performance. And after figuring out direct neighbours you might need to continue further with same tile by going around in larger area to see if it's a 3 tile island or not. Amount of checks required will get really high - even considering that whole ore patch is stored in 2 dimensional table while generating.

It could be made optional - adding second pass after placability check is not that difficult. Figuring out good rules to detect small isles might need some nice algorithm.

I'm not really keen on making any new improvements till v16 of Factorio is around - especially that Rseding91 mentioned somewhere that ability to make sparser ore fields is on his fix list for map gen.
I'm just talking about the beach because while that tile is land it looks like half water and ore on it looks really bad. I have no problem with a 3x3 tile island having ore in the middle.

And since you mention that the ore patch is stored in a 2 dimensional table and I assume places with no ore are simply nil the check should be easy:

Code: Select all

for each tile in (minx-1, miny-1, maxx+1, maxy+1):
    if tile is water:
        for neighbours of tile:
            ore[x][y] = nil

Re: Resources spawning on tiny islands in/around water

Posted: Tue Nov 28, 2017 5:24 pm
by orzelek
I would need to actually make it work on two dimensional table - it uses simple one right now.
And it's not the check itself - it's amount of those checks needed to figure out if given tile belongs to small 3x3 island thats near the water or not. And it requires some non-trivial logic to actually find those properly - I don't think I can query it from game if tile in question is half water or not.

If you have some good algorithm for that let me know - otherwise it's a code that I would need to write from scratch or search for algorithms that might be available on net.

Re: Resources spawning on tiny islands in/around water

Posted: Tue Nov 28, 2017 11:38 pm
by mrvn
As said *I* don't care about the island, only the coastline. Much simpler check.

Look at my pseudocode above. I work the other way around. I go over all tiles below the ore patch (plus 1 tile extra on each side) and check for water. I think there is a lua functions that scan a rectangle with a filter and it gives you a table with all the water tiles. Then you just use a "for" loop to go over them all. That should be highly efficient on land. Not so much in the ocean but that is usually less likely. Then in the inner loop I remove anything from the ore filed that's near water, i.e. a coastline.

You could extend this easily to remove 3x3 island (and smaller) if you remove all ores 2 tiles from a water tile. Means ore will have a greater distance from water all around but on 3x3 island all ore disappears. But that would set 25 ore table entries to nil for every water tile instead of 9 in my smaller case. So more than 3 times slower. To actually check for 3x3 islands is harder. And I don't see a problem with them having ore on them anyway. Just not on the coastline.

Re: Resources spawning on tiny islands in/around water

Posted: Wed Nov 29, 2017 5:26 pm
by orzelek
It's not really that simple and water check would require another api call per each tile in this case.

Currently mod is using placement check to decide if ore can be placed in given location or not. This kind of check doesn't return back any information about why the placement was not allowed. To confirm that it was stopped by water I would need to call the api again in a way you proposed - and api calls are where the main cost is. It could be made optional and disabled by default.
Main thing that would make me reluctant to implement it will be the fact then it can leave for example one ore tile on small island. And then you will be back here stating that it looks wrong ;)

Simpliest option in theory would be to have a marigin around water that ores are not allowed to be spawned in. It would potentially reduce the field size that you get but would eliminate ore from all the small islands.

Re: Resources spawning on tiny islands in/around water

Posted: Thu Nov 30, 2017 11:01 am
by mrvn
I think the placement API call should already include that coastline check. So maybe something to asks the devs to fix and not to bother with in LUA script.