chickadee » linden-scheme » probability

(probability (PROBABILITY BODY ...) ...)syntax

Similar to a cond form, but evaluates a clause based on a given probability. PROBABILITY is expected to be a number less than 1.0, or the symbol else. The sum of all probabilities should add up to 1.0, or less than 1.0 if an else clause is used. Otherwise there is a chance that no clauses will be evaluated (in the case that the probabilities add to less than 1.0 and no else is used) or a clause may never be evaluated (in the case that the probabilities add to more than 1.0).

For example:

   (probability
     (0.1 '((branch (flower)) (apex)))
     (0.7 #f)
     (else '((branch (flower)) (branch (flower)) (apex))) 

describes a 10% chance of creating a branch with a flower, a 70% chance of doing nothing, and a 20% chance of creating two branches with flowers.