Page 3 of 3

Posted: Sun Jan 10, 2016 9:10 pm
by Leress

Posted: Mon Jan 11, 2016 1:55 am
by zeruslord
The thing that needs to be true for a chunk is not that it can be generated without any information about other chunks, just that each stage of generation can be done with only information produced by earlier stages of other chunks. When you go to generate a chunk, you can produce the ground without looking at the full details of the ground of neighboring chunks. Then you look for the randomly generated special features in a specific order - probably biggest to smallest, with some discarding of incompatible features (if there's a castle, don't put a tree in it, that sort of thing), and some way of avoiding conflicts between features in the same tier without expanding the search area - one way to do this might be to check whether there are any in a certain bounding box (say, no castle with its northwest corner north of you or west of you that would overlap) and not place if there is one. Of course, now you are doing partial generation of a larger area (with more and more detail the closer it is to your chunk). Therefore, this needs to be repeatable - probably by having it be a function of the world seed plus the x-y coordinates. Also you might cache anything actually decided about neighboring chunks, but I'm not sure that's necessary.

Posted: Mon Jan 11, 2016 2:16 am
by DSMatticus
Those all touch on generating the landscape, but don't discuss generating (pseudo-)structures like trees and castles. It's a different problem - a block is just a point, and a point is guaranteed to occur in only one chunk. A castle is a 3d shape built out of blocks, and cannot be guaranteed to occur in only one chunk. Which introduces a new concern - coordinating world features across chunk boundaries. I know how games do the former, but have never really seen a gamedev blog about their approach to the latter.
Zeruslord wrote:The thing that needs to be true for a chunk is not that it can be generated without any information about other chunks, just that each stage of generation can be done with only information produced by earlier stages of other chunks. When you go to generate a chunk, you can produce the ground without looking at the full details of the ground of neighboring chunks. Then you look for the randomly generated special features in a specific order - probably biggest to smallest, with some discarding of incompatible features (if there's a castle, don't put a tree in it, that sort of thing), and some way of avoiding conflicts between features in the same tier without expanding the search area - one way to do this might be to check whether there are any in a certain bounding box (say, no castle with its northwest corner north of you or west of you that would overlap) and not place if there is one. Of course, now you are doing partial generation of a larger area (with more and more detail the closer it is to your chunk). Therefore, this needs to be repeatable - probably by having it be a function of the world seed plus the x-y coordinates. Also you might cache anything actually decided about neighboring chunks, but I'm not sure that's necessary.
You're more or less describing what I've suggested - to place structures into the world with a series of initial passes over a larger area than the one you're actually creating and rendering for the player to see. Whether or not to do that in advance and cache it or to just do it over and over at runtime probably wouldn't make much of a difference, depending on how big an area you've decided to sketch - that sort of preliminary work would be an absolutely trivial amount of comp time relative to generating the terrain itself.

Posted: Fri Jan 29, 2016 9:42 am
by tussock
and cannot be guaranteed to occur in only one chunk
Just guarantee that they occur in the one chunk. So when randomly placing them, their bounding corners must be within the chunk, probably by a good few tiles so they don't inappropriately touch other similar features.

Trees meanwhile can edge right up to the neighbouring chunk, so you don't get natural corridors in your forests.

Angband used to generate levels in screen-size chunks, and the big special vaults just had code to make sure they could fit in their own chunk, as did all the smaller rooms, with corridors laid in last to ensure connectivity.