<nodding...>
Lightfoot8 wrote...
The First step is the creation of a seedable random number generator. Since you like the word of chaotic for such a critter we will call it a Chaotic Generator, I also added a High and Low range arguments for ease of use.
Yup, exactly! A Chaotic Number Generator. Provide a iSeed1,iSeed2, iLow, iHigh num and perhaps a curve slope value (i.e. the number of dice rolled?).
Given any set of variables, the CNG will always return a set integer in the range iLow<=result<=iHigh. Plotting the results for a large group of iSeed1 would yield a curve that is flat (iSlope=1) to increasingly steep. Basically, I want the iLow & iHigh probabilities to be very rare.
iSeed1 (which would be the unique index of that particular node, a value of 1-64K)
iSeed2 (which would be the unique index of that particular wp_veg in that area, a value 1-255) might be the number of warm-up iterations of GenerateChaotic() in your example...
Assuming that the Generator is going to be used in a single script Per seeding and the Current postion does not need to be stored into a local. This would be the Include for the Generator.
const int a = 16807; // 7^5 /// x^y is x to the y power in the comments.
const int c = 0;
const int m = 1073741823; // (2^30) -1
int rSeed;
int GenerateChaotic (int nHigh ,int nLow = 1 )
{
*snip*
}
Giving the Generator a unique seed per script based on you request would not be that hard from here.
...
int nSeed = (NodeIndex << + WpIndex;
SeedChaoticGenerator( nSeed);
...
But I don't really want a unique seed when called. I want the seed to be precisely the node index and the wp_veg index, so the value returned is the same *every* time I call it for that wp_veg at *that* particular node.
Example: Node 3141 (whose name just might be Pi's Zadora) might use template area 59 (which is actually named something like "tem_fffh_1ss0_3". Template 59 has a certain wp_veg with an index of 26.
*Every* time Node 3141 wakes up it will load template area 59.
Then it will work through all the wp_veg.
When it gets to wp_veg 26 it calls GenerateChaotic(3141, 26, -9, 9, 3) and returns... 7 perhaps.
It will *always* return 7 for that wp_veg in that Node.
It will always return a different (allowing for the probability of repetition) number for that same wp_veg in *other* nodes (with a possible 64K nodes and a target of 100-200 templates, each template will "serve" hundreds of nodes).
To give the results a bell I would use the same trick used by just about every dice game out there(even though nwn missed the trick in most cases) . Take a great sword for example. It does 2 to 12 damage.
Exactly! Except that the dice roll slope-variable is very coarse grained at small values, and I was sorta hoping a more mathematically insightful scripter would jump in, laugh at all of us (in a friendly, if superior way) and jot down one of those truly elegant one-line equations that makes us all say "Doh! I shoulda thought of that!"
But a value of 3 would actually give me the sort of steep slope I was looking for.
BTW, your pm idea for fractally generating the distribution is pretty interesting, too. I just don't like the precise placement (location) being algorythm. Too much chance for ugly groupings and border-of-tile drops. Not insurmountable challenges, but, for now, I think the seeded wp idea will be easier, quicker and (thanks to FB!) already implemented ;-)
Even though NWN handles this as a D6 *2...
<jaw drops in astonishment>
They *didn't*! Oh, *please* say you're joking? <looks rather completely disillusioned>
I... don't have anything to say about that. Nothing good.
...It really should be 2D6, Making a roll of 7 the most common and 2 and 12 the hardest rolls to get, Just like the game of craps. For your results however, since it is hard to roll a 9.5 die to get the range you want, I suggest just getting the average of two Chaotic numbers in the range you want for the same result.
int nResult = (GenerateChaotic(9,-9) + GenerateChaotic(9,-9)) / 2;
If you wanted a function to controll the dx of the bell It would not be that complex with this system. It could however start burnning up the instruction count if you started getting to many itterations. *code snipped*
Yes, adding a slope (incline, dx) to the function, at least until we found a comfortable setting, would be good.
And that would make the function more generally available for *other* spawns, like carnivores, herbivores, citizens in cities... etc.
I hope that answers the original question.
L8.
Yup :-) Thank you very much :-)
Modifié par Rolo Kipp, 26 décembre 2011 - 08:03 .