It takes a heightfield, a probability map, an average distance, a minimal distance and generates a distribution (1st pass).
If relax is = true, all generated positions will be iterated in descending order of field probability (so that items with high field probability have more influence over lower probability items in terms of position stability) and too near items are pushed away, if the minimum distance is violated (2nd pass). If the previously generated random item probabilty then violates the (predefined) field probability, the item will be deleted; otherwise it gets updated (height and field probability).
Then, in the 3rd pass, pairs are searched for, that still violate the minimum distance, and are deleted as well.
After finishing this, for each item a callback will be called and the heightfield, the XYZ coordinates (in heightfield space) and the field probability at that location are passed. This gives me the opportunity to decide by myself what to do for each generated item: