Genre: Other Genres
About CatweaselLocation: Barnsley, S Yorkshire, UK Home Region: Age:34 Website: http://www.dewimorgan.com |
Joined: November 4, 2007 This Year: Official Participant NaNoWriMo History: NaNoWriMo posts: 50 NaNoWriMo buddies: 26
|
|
|
|
Synopsis: A collection of short stories, and MMO code.
Last year, I wrote a novel, and got bored. This year, I need to get a ton of code done, and this seems a good way to get myself to do it. I will also write short stories if I get bored of the coding.
Excerpt: A collection of short stories, and MMO code.
Public Class WorldGenerator
'Read in terrain bitmap and heightmap.
'Scale to required size.
'Generate more detailed heightmap (possibly as tesselant: 1km squares
' everywhere, then 100m squares around the current square, then 1m squares
' in current square?
'Strata
' - store the 'normal' vector of the underlying strata, then when generating
' slopes, make them tend either toward the normal, or toward a plane
' perpendicular to it, whichever is closer. Make the tendency vary according
' to the strength of the strata vector. Where it is decided that the rock is
' exposed (wherever the slope is steeper than X degrees?), display strata
' from the global 'rock sandwich image', aligned according to the height of
' the vector, so that strata can line up over entire continents.
' - [Remodify the heightmap to account for strata]
' - Sandy/pebbly beaches: No idea how to do these, though if I'm luckier
' than I deserve, beaches below cliffs may fall naturally out of the
' scree/talus code, and beaches away from cliffs can just be a terrain type
' near where land meets sea. Ideally I'd have a system that makes headlands
' tend to be rockier, steeper, and less beachy than coves.
'Geological features: cliffs and mountains
' - cliffy coastlines: specialcase them to not pay attention to height of
' stuff to the seaward side, and instead generate from "virtual" terrain that
' has "eroded into the sea" instead.
' - At hub, cliffs should just happen.
' - Elsewhere, could depend on strata angle. Fractals with
' strata-sensitivity could generate believable cliffs. But need to be
' recorded as linear entities particularly if zone-crossing.
' - Cliffs are significant linear deformations in ground height, might
' affect the level of the underlying strata if they're caused by faulting,
' but not if they're caused by erosion.
' - Scree/talus: I can just add a rule that X% of the cliff height be
' diagonal.
' - [Remodify the heightmap to account for geological features]
'Dunes:
' - cheat with this, have any dunes be static. Still a challenge to generate
' them the right shape, though. While they look fractal, it's a directed,
' meaningful kind of fractal. There are aeolean shapes the size of whole
' countries there, and I just don't see any way to generate those without
' very heavy cheating. So I'll just go for the smaller dunes, because people
' can't see larger features anyway, they're too big.
'Waterway paths
' - "cost" for each potential path in a zone needs to be calculated. cost
' (in the direction of flow) = max vert distance from start point to the end
' point, along lowest possible route. So if the lowest possible route passes
' over a 1km-high mountain range, the cost would be 1000. If the lowest
' possible route took it down ten metres, and passed over no lumps, then the
' cost is -10.
' - A simple maze generation algorithm that repeatedly places a link at the
' cheapest transit it can find to an linked zone (means all zones only have
' one river exiting them)
' - Within those areas, a certain amount of randomness to the river path,
' enough that on a reasonable hill it would not affect it, but on essentially
' flat terrain the path would be close to random. This would give me the
' illusion of consequent and insequent rivers, which should, I hope, be
' enough to be convincing. Maybe even a system to generate oxbows in places
' where the land is very flat & softish.
' - Sediment at river mouths: This could be a tricky one. I was planning on
' purely dendritic rivers, because that's just the easiest to generate. But
' in deltas, it would be nice to have the path split around sediment banks
' and stuff. Islands in larger rivers would be nice too.
'Waterway volumes
' - The size of the waterway on entering a zone will be the size of all
' waterways that feed into it. The size on exit will be that, plus the size
' of any other zone-crossing rivers that joined it during the zone, plus the
' average rainfall of the terrain type of the current square, minus an
' "evaporation" amount for really hot terrain types, and those where
' irrigation is used. This can easily be calculated with depth-first
' recursion. I could cull all zero-size rivers (would be common in deserts,
' for instance), but I like the "dry riverbed" idea - it gives an impression
' of history.
' - [Remodify the heightmap to account for waterway erosion]
' - Possibly also http://en.wikipedia.org/wiki/Erosion_prediction
'"seed towns": Primary-level population centres and agriculture.
' - [Remodify terrain typemap to include manmade changes,
' waterway-imposed swamps, etc.]
'Roads and other forking entities.
' - unidirectional, cost = abs(distance * slope * height), so a 10km 1%
' slope that goes up (or down) 100m only has a cost of 10,000, but 100m
' vertical cliff (100% slope) with 10km of flat plain above and below it, has
' a cost of 1,000,000. Also, "bridging" cost for going over a river, possibly
' river's size squared or something.
' - For each population centre, identify the N nearest neighbours and lay a
' road to each. N is an arbitrary number that determines how long
' calculations will take, and how accurate the results will be. There's a
' rapid falloff of how important they are. One road per town would be
' stupidly small, but ten would probably be excessive for all but the largest
' cities: most villages have only a couple of roads passing through, which
' would be four roads leaving.
' - Then remove any closed networks: make a list of all roads. Pick a road,
' and work your way through the network, removing all connected roads from
' the list. Do the same for the next (remaining) road. Repeat, and you will
' have a list of roads which are members of the isolated groups. Link them
' all, in a ring or something. It doesn't matter that you are not linking the
' nearest parts of the closed networks: the next step will deal with that and
' make it realistic. But there are nicer ways you could do this, like make
' each link from one closed network to its neighbours come from a different
' city.
' - Give each road a "size" value, which is:
'(sum of both endpoint populations using it)/(N * length). We're dividing by
' N since if a town only has one road leading from it, then it will be more
' travelled than if it has two. We're dividing by length as the number of
' people on the road will (simplistically and ignoring rush hour, night time
' etc) be spread evenly out over its length. The "length" value of the road
' however, is equal to the terrain cost that it passes through, not its
' length in space. The size, then, is the number of people per unit "length"
' that would be on the road if you sent everyone walking out from a city
' along a random road.
' - Now each road has a "gravity" value, distributed as a rope with a mass
' (the "size" value) spread evenly over its length, which can be considered
' to be split into manageable sized "sections" with a mass applied in the
' centre and connected to each other by springs with a strength that is again
' dependant on size. Each city has a gravity value, which is its population,
' and is applied at a point in its centre.
' - Apply these gravities to road nodes. Where road sections merge, add them
' together. Any road which passes within a population centre's radius gets
' linked to that town and the town's N increases by 2, which has knock-on
' effects to all other roads it is connected to. Merge all road sections with
' an angle between them less than some critical angle like 15 degrees. Any
' road that stretches "long" enough for a new section to be inserted, does
' so. Repeat iteratively until the system becomes stable (so, no road merges
' were made for the last N loops), or you get bored iterating.
' - Possibly either give rivers attractive gravity, or make riverbanks have
' a low travel cost.
'Towns
' - Other than the "seed towns", towns need to be randomly generated
' entities.
' - They should appear by crossings of linear entities. A bridge, a fork in
' a river, a road down a cliff, a river hitting the coast. The larger the
' "size" of the entities that cross, the larger the chance that there will be
' a town there, the larger the dice used to generate the population size of
' the result, and the larger the radius of the town. So you need to grow
' these iteratively, since a small hamlet at a road entering a mountain pass
' may, once placed, have a river fall within its boundary, which will
' increase the population and hence radius enough that it overlaps the farm
' at the nearby bridge, and then the village grows larger and now has enough
' gravity that it can pull a road node into itself, and so it grows, until it
' hits stability and can't grow further. This iterative process should
' probably be done at the same time as the above road one.
' - There should probably be a total population cap, possibly a total
' population density cap that can be supported by each terrain type or
' something.
'Linear nonforking entities.
' - [Loop back to generate secondary level pop centres, then tertiary, etc
' down to hamlets]
'Clutter
' - Topples: these would have to be separate items, rather than just
' deformations of the terrain mesh, so would be placed at a later stage. Item
' placement is based partly on terrain type, so I can just increase the
' "large rock slab" chance near cliffs, I guess.
' - Volcanism: I kind of feel that volcanoes would be rare enough I could
' hand place them, so they needn't be generated automagically. Molten treacle
' volcanoes are an amusing enough idea that I would like to make at least
' one, though.
' - Karst, badlands, coral reefs/atolls, unconformities: No idea how to do
' any of these. Not sure their lack would be jarring to people, either, but
' if there are easy ways to fake 'em, they'd be "nice touches".
#Region "Class consts and vars"
'The heightmap, 24 bit. Interestingly, 2^24 mm = 10.4248787 miles.
'Cori celesti is 10 miles high, so 1 heightmap increment = 1px.
'As we need some depth for the ocean, sea level is set to 777216,
'so that the top 16,000,000mm are aboveground.
Dim m_HeightMap As Bitmap
'Terrain map. 24bits, so either 2^24 gradations of terrain, 24 flags,
'or some combination thereof.
Dim m_TerrainMap As Bitmap
'Bitmap with a few feature types listed. It's a 3-byte-per-pixel (24bit)
' non-lossy bitmap, so each pixel can contain one or more of the 24 types.
Dim m_FeatureMap As Bitmap
#End Region
#Region "Event Handling Functions"
Private Sub ButtonHeightMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonHeightMap.Click
m_Heightmap = New Bitmap(Strings.GetOpenFullPath("Select Heightmap", Globals.PHOTO_GLOBS, Globals.BitmapPath, "heightmap"))
End Sub
Private Sub ButtonTerrainMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTerrainMap.Click
End Sub
Private Sub ButtonFeatureMap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonFeatureMap.Click
End Sub
#End Region
End Class
Catweasel's Writing Buddies
|
|


add as buddy
send NaNoMail
visit website