<striking a spark into the tinder...>
Ok, this will be a bit long-winded, but I gotta be me :-)
This post actually concerns (among other things) "Vegetation Distribution in
Regional Nodes Using Template Areas".
The Goal: To distribute vegetation in a consitent, but unique manner in each regional node using template areas. (Something in some ways similar to
Skipnuttz idea of algorythmically generating tree placeables)
Problems: There may be thousands of nodes, with hundreds using the same template area. Random placement will not work as the layout of the map would change everytime the node was woken up (completely defeating the purpose of using nodes for consistency). Static placement in the template area will not work as every node using that template would look the same.
What is required is a chaotic algorythm for distributing vegetation in a variable probability, unpredictable fashion that is consistent
per node.
(Chaotic vs. Random: Random functions will return different, unpredictable values every time. Chaotic will always return a consistent, but unpredictable value for the same "seed value".)
Set up: Each template area will have a variable number of waypoints (green flag - "wp_veg_(AreaIndex)") for placing vegetation in reasonable places (placed by design).
The WakeUpNode() function will (among other things) step through all wp_veg's for the area and call a GetVegValue() function seeded with the NodeIndex and the WpIndex (a local int stored on the wp_veg the first time it's called giving each a unique index).
GetVegValue() will return an int in the range -9 to +9.
The values should be generated in a bell curve that peaks at 0. (Edit: there should be very few +/- 9s, and about half should be negative values)
Negative values will be clipped (values <1 will result in no vegetation for that wp_veg).
With the default state, this means that about half the wp_veg will be empty, that most wp_veg will spawn low-level vegetation and that the *same* vegetation will spawn (in any given state) *every* time the node wakes up (for any given NodeIndex|WpIndex seed).
Dynamic States: Getting the range in a bell curve with negative clipping allows a very neat little trick that ties into my Dynamic States system; The default state modifies the VegValue by 0 (that is unmodified).
If the state of the node is below normal (say logged or even clearcut), the VegValue is decremented by up to -4, giving a new range of vegetation from -13 to 5 with the peak probability being -4. At the worst possible state (not counting special states, which is a different subject), *most* of the wp_veg would be empty and the highest possible wp_veg is 5 (small tree) - only a very few of them.
If the state of the node is above normal (deep forest, mature forest or even climax forest), the VegValue is incemented by up to +4, giving a new range of -5 to +13 (values >9 are considered 9) with the peak distribution being at +4 (small trees) and a huge shift toward the number of Giant trees placed.
One more point about how this ties in to dynamic states: The highest value wp_veg points are *always* the highest value wp_veg. That small tree in the clearcut state will be the growth leader as the state improves toward climax forest. *That* tree will always be among the largest in that node. Similarly, the weakest wp_veg points will always be the weakest, and will be the first points to lose their vegetation.
The Question: I got this far before my coffee got cold ;-P So, what would be a good function to return chaotic integers in the range -9 to +9, with a bell curve distribution that peaks at 0, given two seed values - NodeIndex (range 1 to ~64K) and WpIndex (range 1 to 255)?
<...and blowing hard>
Modifié par Rolo Kipp, 24 décembre 2011 - 07:06 .