[b][url=http://www.java-gaming.org/topics/main/27002/view.html]Main[/url]/[url=http://www.java-gaming.org/topics/procedural-content/27072/view.html]Procedural content[/url][/b]
STUB (YEAH, I&amp;#039;M MAKING LOTS OF THESE) TO REMIND MYSELF TO DO A WRITE-UP.
[h2]Uniform Feature Points[/h2]\nLet us imagine that we have a 100x100 meter field and in this field we what there to be, on average, two flowers per meter squared. So we could create an array with 100x100x2 = 20,000 elements to explicitly store the positions of each flower. Using a seeded uniform random number generator we could then fill the array with repeatable coordinates for each. If we were to examine the placement of flowers we would notice that there would be regions with none and areas where they are clummped up. Now if were to examine each square meter (or some other regular chunk) and count the number of flowers it contains, then the &amp;quot;distribution&amp;quot; of the counts matches the Poisson distribution.So instead of precomputing a explict list of &amp;quot;features&amp;quot;, the space in question can be broken down into parts. For each part one computes a poisson random number to determine the number of features inside it.
Example code from Knuth:
[code]
rng.setSeed(someValue);
for(int i=0; i&amp;lt;100*100*2; i++) {
float x = 100*rng.nextFloat();
float y = 100*rng.nextFloat();
doMyFlower(x,y);
}
[/code]
Now if were to examine each square meter (or some other regular chunk) and count the number of flowers it contains, then the &amp;quot;distribution&amp;quot; of the counts matches the Poisson distribution.
So instead of precomputing a explicit list of &amp;quot;features&amp;quot;, the space in question can be broken down into parts. For each part one computes a poisson random number to determine the number of features inside it.
[code]
// From Knuth, reasonable on modern machines for smallish
// means. There are many ways this can be computed.
// eMean = exp(-mean)
prublivc stateic final int poisson(float eMean)
{
int r = 1;
float t = rng.nextFloat();
while (t &amp;gt; eMean) {
r++;
t *= rng.nextFloat();
}
return r-1;
}
// Sketch below this point
private static final float FLOWER_POWER = (float)Math.exp(-2);
private void doSomeCellFlowerThing(...)
{
rng.setSeed(hashOfThisCell);
int num = poisson(FLOWER_POWER);
for(int i=0; i&amp;lt;num; i++) {
// coordinates local to the square meter in this example
float x = rng.nextFloat();
float y = rng.nextFloat();
...
}
}
[/code]

STUB (YEAH, I'M MAKING LOTS OF THESE) TO REMIND MYSELF TO DO A WRITE-UP.

Uniform Feature Points

Let us imagine that we have a 100x100 meter field and in this field we what there to be, on average, two flowers per meter squared. So we could create an array with 100x100x2 = 20,000 elements to explicitly store the positions of each flower. Using a seeded uniform random number generator we could then fill the array with repeatable coordinates for each. If we were to examine the placement of flowers we would notice that there would be regions with none and areas where they are clummped up.

Now if were to examine each square meter (or some other regular chunk) and count the number of flowers it contains, then the "distribution" of the counts matches the Poisson distribution.

So instead of precomputing a explicit list of "features", the space in question can be broken down into parts. For each part one computes a poisson random number to determine the number of features inside it.

// From Knuth, reasonable on modern machines for smallish// means. There are many ways this can be computed.// eMean = exp(-mean)publicstaticfinalintpoisson(floateMean){intr = 1;floatt = rng.nextFloat();

Basically the difference is that quasi-random will give better coverage, which is more regular...less clumps & empty areas. Actually the wikipedia picture gives pretty good idea: http://en.wikipedia.org/wiki/Halton_sequence

So instead of precomputing a explict list of "features", the space in question can be broken down into parts. For each part one computes a poisson random number to determine the number of features inside it.

Then what? Once you know how many flowers are in a certain grid location, how do you distribute them within it? What do you do about edges and corners?

According to that code they are randomly distributed within a cell, not uniformly distributed inside of it. A group of four cells could potentially could have a greater density of flowers around their shared corner and much lower density everywhere else. The same could apply to edges with two cells. Within one cell, multiple flowers could clump together.

They need to be uniformly distributed with respect to other objects in the same cell as well as to those in neighboring cells.

According to that code they are randomly distributed within a cell, not uniformly distributed inside of it....They need to be uniformly distributed with respect to other objects in the same cell as well as to those in neighboring cells.

BUE & Danny02: you're both using a non-probability based notion of uniform or more specifically a uniform random process. Added some text to deal with the notion of "uniform".

A group of four cells could potentially could have a greater density of flowers around their shared corner and much lower density everywhere else. The same could apply to edges with two cells. Within one cell, multiple flowers could clump together.

All these examples and opposite versions of them are likely and desirable. It's exactly what's suppose to happen. If you were to create two images with points, one globally and the other by breaking into parts and using poission and randomly choose to display one on the right and left...you shouldn't be able to identify which is which. If you can, then the hashing isn't working.

The various test-suites of PRNG quality will perform many operations in the opposite direction from this. Create a bunch of points in 'n' dimensions, then break that space up into various sized parts..count the number of contents inside each part and if the values don't approach the Poisson distribution, then it fails the test...the PRNG is not creating uniform random numbers in that number of dimensions.

I see. You're talking about emulating a process where each point's location coordinates are selected at random with uniform probability. Not that the generated graphics look uniformly distributed. You had me confused when you were talking about the Halton sequence.

Or in other words, uniform like rolling a fair dice twice and plotting the values as x-y coordinates - but not uniform like a uniform distribution of points.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org