Article View: rec.games.programmer
Article #29Re: Fractal Map Generation ?
From: Gavin Dodds
Date: Tue, 27 Oct 1992 10:56
Date: Tue, 27 Oct 1992 10:56
49 lines
3782 bytes
3782 bytes
I'm gona get flamed for mentioning my computer, but here goes.
I have recently written two random landscape generators on my C64. Each one picks a random number of hills and heights of hills.
The first one also has a 'level width' number which is random, and represents the distance between contour lines. It then goes on to produce rounded hills with a square's height beeing dependant on the distance from the centre point, the height of the hill and the level width. Using this formula;
Height = HillHeight - (Distance from centre / level width)
Checks are made for height < 0 on each square (you can use these to put in seas etc.)
The second and subsiquent (sp?) hills take the value of the height of their centre square and add it on to the random hill height. Also to ensure smooth flowing of hills into each other, if the value computed as above is less than the value already stored for that square, then the higher value is left unchanged.
The second generator creates Populous style pyramidal hills by working the height out as follows.
Height = HillHeight - MaxDistance
Where MaxDistance is the distance in the x or y direction of the square from the centre point that is the largest.
Using lots of either (or both together) of these hill types superimposed on each other, a respectable relief map can be built up, especially if the x,y co-ords of the centre of the hill can be influenced to cluster together to give mountain ranges, islands etc.
As for rivers. I invented a system whereby the river can only move N, S, E or W from the square you currently consider. Which direction your procedure decides to move it in depends on what is already in that square and it's surrounding four squares. Each of the four squares is given a value (the lower the more likely the river is to move into that square). Start with a base of the heights of the squares, then modify according to a system like this;
Straight ahead -1
Left or Right +0
Backwards +6
Uphill +2
Downhill -1
etc.
The modifiers for up and downhill are to cancel out any advantage gained by going ahead. (eg left downhill is better than ahead uphill) Backwards should NEVER be allowed. You can also put in checks for rivers looping, joining and running into a dead end.
You could remember where left or right turns are made and give each a chance of being a branching point (Based on the scheme above if you like).
When the river reaches the edge of the map, or a sea, lake or other river then it will stop and you can consider branches as seperate rivers.
I hope this will be of use to you and I hope I don't get flamed for having a C64!
GAV
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: "Get down!", "Get out!" :: GAVIN DODDS ::
:: "Wrong!", "Stick around" :::::::::::::::::::::::::::::::::::::
:: "Trust me!", "I'll be back!" ::Email-Gavin.Dodds@uk.ac.newcastle::
:: "You are one UGLY Motherfucker!" :::::::::::::::::::::::::::::::::::::
:: "I like you, Sully, ... That's why I'm going to kill you last" ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Technical Details
Message-ID:
<Bws130.HrI@newcastle.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!pipex!warwick!uknet!newcastle.ac.uk!turing!n0ancReferences:
<MAT.92Oct25230450@coral.math.arizona.edu> <1992Oct26.152345.26208@mnemosyne.cs.du.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pipex!warwick!uknet!newcastle.ac.uk!turing!n0anc From: Gavin.Dodds@newcastle.ac.uk (Gavin Dodds) Newsgroups: rec.games.programmer Subject: Re: Fractal Map Generation ? Message-ID: <Bws130.HrI@newcastle.ac.uk> Date: 27 Oct 92 10:56:59 GMT References: <MAT.92Oct25230450@coral.math.arizona.edu> <1992Oct26.152345.26208@mnemosyne.cs.du.edu> Organization: Computing Laboratory, U of Newcastle upon Tyne, UK NE1 7RU. Lines: 49 Nntp-Posting-Host: galewood