module FractionLife

Public Class Methods

generate(odds=0.5) click to toggle source

generate is FractionLife's only method. It returns a random integer as described above.

If the odds param is given, that value is used to indicate the probability of each iteration returning a value. So, for example, this call:

FractionLife.generate(0.75)

has a .75 chance of returning 1.

# File lib/fraction_life.rb, line 15
def self.generate(odds=0.5)
        rv = 1
        
        # check random value
        while rand() > odds
                rv += 1
        end
        
        # return
        return rv
end