Terrain Algorithm


#1

Without going into explicit detail into the code, how does the terrain algorithm work? I think it can be used for some interesting tiling, but I don’t want to trial-and-error my way through the whole process.


(Thorbjørn Lindeijer) #2

For each edited position, it tries to find the tile best matching the resulting terrain pattern, choosing randomly between candidates if there are multiple (or doing nothing if no suitable tile was found). Then, if the neighbors of this position do not match up with the chosen tile, it tries to replace them with another tile that does match while keeping the needed changes to a minimum. This process continues until it runs out of positions looking for a better tile. Each position is only evaluated once, which is both a reason for the speed of the tool as well as the reason for its erratic behavior in case the available transitions in the tileset are incomplete.


#3

Great, thanks for explanation.