Page 1 of 1

How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 10:48 am
by ficolas
I am making world generation for my mod, and I was thinking:
I need to generate the world inside the chunks that are loaded, or it may not work... but how many chunks are loaded?
So I need to know that to make the worldgen part of the f mod

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 10:53 am
by MF-
I am not sure that there is any chunkloading/unloading.
Shouldn't unloading the chunks with your power plant kill your power?

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 10:58 am
by ficolas
Im not sure about chunk unloading, but im sure about chunk loading ( the map is infinite, but it generates when you go throught the chunks), obiously, your computer cant interpretate infinite chunks.

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 1:12 pm
by kovarex
All generated chunks are active all the time.
Providing event like "chunk-generated" could help.

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 1:15 pm
by ficolas
but how many chunks are generated? what distance from the player

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 6:03 pm
by FreeER
Probably the most useful answer here would be how many 'chunks' are generated around the player at start (assuming that is the buffer around the player where if a chunk is not loaded it becomes loaded).
ficolas wrote:I am making world generation for my mod, and I was thinking:
I need to generate the world inside the chunks that are loaded, or it may not work... but how many chunks are loaded?
So I need to know that to make the worldgen part of the f mod
Well assuming that your terraforming worked based off placing a machine down then (once we know) as along as it doesn't go farther than what the buffer is around the player it would work fine. I'd take a wild guess (until we get an answer) that it's only slightly more than the size of the minimap. Which would still be a fairly insane amount of land to terraform, even if it took an hour or two :)

PS. this would explain for sure why my 71 mb save is down to only 20fps :) perhaps a console command to unload chunks more than x away from the player could be implemented so I can actually play this save again lol?

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 6:33 pm
by ficolas
I think the game should unload the chunks, for multiplayer, it needs to be done if multiplayer will be public server based (I hope it is like so) and im sad that world gen will be so bad in my mod, becaise the player will be so near to the player, or I just had an idea xD, the worldgen wont be runned untill the player is near.

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 7:00 pm
by MF-
ficolas wrote:I think the game should unload the chunks, for multiplayer, it needs to be done if multiplayer will be public server based (I hope it is like so) and im sad that world gen will be so bad in my mod, becaise the player will be so near to the player, or I just had an idea xD, the worldgen wont be runned untill the player is near.
Agreed, there will be a need for chunkloading in the future.
On the other hand - I am not sure that unloading inactive chunks (those that have no running machinery) would improve the situation.

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 11:34 pm
by slpwnd
MF- wrote:On the other hand - I am not sure that unloading inactive chunks (those that have no running machinery) would improve the situation.
Good point. I don't have the data however I would guess that unloading the chunks wouldn't help that much because there are mostly just fish and creepers there.

Re: How many "chunks" are loaded?

Posted: Sat Mar 16, 2013 11:49 pm
by Lukasecicek
I have sort of solution for the performace, with the help of actual "factory" buildings. Will write it down into detail right after i get some sleep.

Re: How many "chunks" are loaded?

Posted: Sun Mar 17, 2013 3:10 am
by kovarex
The radius is up to 3 chunks far from the player (so 7X7 chunks around the player should be always there).
Chunk is 64X64 tiles.

Concerning the performance issues, there is lot of optimisations that can be done, and later, we can implement multithreaded game update as well, so don't worry the limits will get much bigger.
I don't know how does it work in your maps, but the results of our profiling showed, that most of the time of the update was spent in the factory.

Re: How many "chunks" are loaded?

Posted: Sun Mar 17, 2013 3:44 am
by FreeER
so 49 chunks minimum (3 on each side and the chunk the player is in) at start. I'm assuming there is no way to currently tell if a chunk is unloaded yet (for instance you wanted to use game.createentity out at say x=5000 y=5000, or would the game load the chunk before it tried to create an entity there)? Not a huge issue if your doing something around the player since the world never UNloads right now :) Have you decided which update will include world gen possibilties?

edit: btw, just created a stone furnace at 5k, 5k and teleported to check it out. It created the furnace fine...I lagged on teleport and was pretty much instantly killed by creepers :) ah, what a sight to behold however :lol:

edit again: um, just wanted to recommend that you do NOT try teleporting to 50k, 50k...it literally took win 7 over five minutes just to tell me that factorio had stopped responding :) and ate 96% of my 6 GBs of ram + 76% of my swapfile (5.6 GB) lol, cpu was only about 25% but that could be because factorio isn't multi-threaded (yet ) :lol: This makes me wonder how chunk loading works when teleporting however, if it only loaded the 49 chunks around me at spawn and then the 49 chunks at 50k,50k it shouldn't have crashed like it did (at least I wouldn't think so).

Re: How many "chunks" are loaded?

Posted: Sun Mar 17, 2013 9:04 am
by MF-
Here is a fun *hypothesis*:

Creeper spawners might be placed in the same way as items when you remove a chest (they explode around)
at 50k,50k there was a lot of spawners "in the chest that exploded".
So much that there is actually more spawners to be exploded around than the actual space.
And that would probably cause infinite terrain generation.

Re: How many "chunks" are loaded?

Posted: Sun Mar 17, 2013 10:54 am
by ficolas
Ok so I can place entities far away, but the question is:
Why?
Because the chunk loads when the entity is placed?
or because the entity is placed in an unloaded chunk?

the first one let me do world gen, the second one doesnt, I need to clear the terrain by removing all entities there...

Re: How many "chunks" are loaded?

Posted: Sun Mar 17, 2013 6:32 pm
by FreeER
just try it and see what happens :) that's what I did (and almost regretted it when i teleported to 50k,50k lol)