Skip to main content

Fast & Flexible Random Value Generator

Project description

Fortuna Beta: Fast & Flexible Random Value Generator

Adventures in Predictable Non-determinism
More than just a high performance random number generator.
Fortuna can help you build dynamic rarefied random value generators and more. \ See the treasure table examples in .../fortuna_extras/fortuna_examples.py

Notes
Public Beta: Fortuna is under active development, and may evolve without notice.
Ranges: All ranges are inclusive unless stated otherwise.
Installation: Open your favorite unix terminal and type pip install Fortuna or download and build from source.

Fortuna Random Functions

Fortuna.random_range(lo: int, hi: int) -> int
Input argument order is ignored.
Returns a random integer in range [lo..hi] inclusive.
Up to 15x faster than random.randint()
Flat uniform distribution.

Fortuna.random_below(num: int) -> int
Returns a random integer in the exclusive range [0..num) for positive values of num.
This function is analytically continued for input values of less than one.
This makes the name random_below loose some meaning, random_to_zero may be better.
Returns a random integer in the exclusive range (num..0] for negative values of num.
This function never returns the value of num except in the case where num == 0
As a result, it will always return zero if num is in range [-1..1]
Flat uniform distribution.

Fortuna.d(sides: int) -> int
Represents a single die roll of a given size die.
Returns a random integer in the range [1..sides]
This function is analytically continued for input values of less than one.
Flat uniform distribution.

Fortuna.dice(rolls: int, sides: int) -> int
Returns a random integer in range [X..Y] where X == rolls and Y == rolls * sides
Represents the sum of multiple rolls of the same size die.
This function is analytically continued for input values of less than one.
Geometric distribution based on the number and size of the dice rolled.
Complexity scales primarily with the number of rolls, not the size of the dice.

Fortuna.plus_or_minus(num: int) -> int
Negative and positive input values of num will produce equivalent distributions.
Returns random integer in the range [-num..num]
Flat uniform distribution.

Fortuna.plus_or_minus_linear(num: int) -> int
Negative and positive input values of num will produce equivalent distributions.
Returns random integer in the range [-num..num]
Zero peak geometric distribution, triangle.

Fortuna.plus_or_minus_curve(num: int) -> int
Negative and positive input values of num will produce equivalent distributions.
Returns random integer in the range [-num..num]
Zero centered gaussian distribution, bell curve: mean = 0, variance = num / pi

Fortuna.percent_true(num: int) -> bool
Always returns False if num is 0 or less, always returns True if num is 100 or more.
Any value of num in range [1..99] will produce True or False.
Returns a random Bool based on the probability of True as a percentage.

Fortuna.random_value(arr) -> value
Returns a random value from a sequence (list or tuple), uniform distribution, non-destructive.
Up to 10x faster than random.choice()

Fortuna.pop_random_value(arr: list) -> value
Returns and removes a random value from a sequence list, uniform distribution, destructive.
This function is not included in the Fortuna test suite due to it's destructive nature.
This is the only destructive function in the module, use with care. It will raise an error if the list is empty.

Fortuna.cumulative_weighted_choice(table) -> value
Core function for the WeightedChoice base class.
Produces a custom distribution of values based on cumulative weight.
Requires input format: [(weight, value), ... ] sorted in ascending order by weight.
Weights must be unique positive integers.
See WeightedChoice class for a more comprehensive solution that verifies and optimises data.
Up to 15x faster than random.choices()

Fortuna.zero_flat(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Flat uniform distribution.

Fortuna.zero_cool(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Zero peak, geometric distribution, half triangle.

Fortuna.zero_extreme(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Zero peak, gaussian distribution, half bell curve: mean = 0, variance = num / pi

Fortuna.max_cool(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Max peak (num), geometric distribution, half triangle.

Fortuna.max_extreme(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Max peak (num), gaussian distribution, half bell curve: mean = 0, variance = num / pi

Fortuna.mostly_middle(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Middle peak (num / 2), geometric distribution, half triangle.

Fortuna.mostly_center(num: int) -> int
Returns a random integer in range [0..num] or [num..0] if num is negative.
Middle peak (num / 2), gaussian distribution, half bell curve: mean = 0, variance = num / pi

Fortuna Utility Functions

Fortuna.min_max(num: int, lo: int, hi: int) -> int
Used to force a number in to a predetermined range.
Returns num if it's in the range [lo..hi]
Returns lo if num is less than lo. Returns hi if num is greater than hi.

Fortuna.analytic_continuation(func: staticmethod, num: int) -> int
Used to map a positive only function to the negative number line for complete input domain coverage.
The "C" version of this function is used throughout the Fortuna extension.
The function to be analytically continued must take an integer as input and return an integer.

Fortuna Random Classes, Sequence Wrappers

Random Cycle: The Truffle Shuffle

Returns a random value from the sequence. Produces a uniform distribution with no consecutive duplicates and relatively few nearly consecutive duplicates. Longer sequences will naturally push duplicates even farther apart. This behavior gives rise to output sequences that seem much less mechanical than other random_value sequences.

  • Constructor takes a copy of a sequence (list or tuple) of arbitrary values.
  • Sequence length must be greater than three, best if ten or more.
  • Values can be any Python object that can be passed around... string, int, list, function etc.
  • Features continuous smart micro-shuffling: The Truffle Shuffle.
  • Performance scales by some small fraction of the length of the sequence.
from Fortuna import RandomCycle

random_cycle = RandomCycle(["Alpha", "Beta", "Delta", "Eta", "Gamma", "Kappa", "Zeta"])
random_cycle()  # returns a random value from the sequence, cycled uniform distribution.

Quantum Monty: previously named Mostly

A set of strategies for producing random values from a sequence where the probability
of each value is based on the monty you choose. For example: the mostly_front monty
produces random values where the beginning of the sequence is geometrically more common than the back.

  • Constructor takes a copy of a sequence (list or tuple) of arbitrary values.
  • Sequence length must be greater than three, best if ten or more.
  • Values can be any Python object that can be passed around... string, int, list, function etc.
  • Performance scales by some tiny fraction of the length of the sequence. Method scaling may very slightly.
from Fortuna import QuantumMonty

quantum_monty = QuantumMonty(["Alpha", "Beta", "Delta", "Eta", "Gamma", "Kappa", "Zeta"])
# Each of the following methods return a random value from the sequence
quantum_monty.mostly_front()    # Mostly from the front of the list (geometric)
quantum_monty.mostly_middle()   # Mostly from the middle of the list (geometric)
quantum_monty.mostly_back()     # Mostly from the back of the list (geometric)
quantum_monty.mostly_first()    # Mostly from the very front of the list (gaussian)
quantum_monty.mostly_center()   # Mostly from the very center of the list (gaussian)
quantum_monty.mostly_last()     # Mostly from the very back of the list (gaussian)
quantum_monty.mostly_flat()     # Uniform flat distribution
quantum_monty.mostly_cycle()    # Cycles the data with RandomCycle (cycled uniform flat)
quantum_monty.quantum_monty()   # Quantum Monty Algorithm (complex non-uniform)

Fortuna Random Classes, Table Wrappers

Weighted Choice: Custom Rarity

Two strategies for selecting random values from a sequence where rarity counts.
Both produce a custom distribution of values based on the weights of the values.
Up to 10x faster than random.choices()

  • Constructor takes a copy of a sequence of weighted value pairs... [(weight, value), ... ]
  • Automatically optimizes the sequence for correctness and optimal call performance.
  • The sequence must not be empty, and each pair must have a weight and a value.
  • Weights must be integers. A future release may allow weights to be floats.
  • Values can be any Python object that can be passed around... string, int, list, function etc.
  • Performance scales by some fraction of the length of the sequence.

The following sub-classes produce equivalent distributions with comparable performance. The choice to use one over the other is purely about which strategy suits you or your data best. Relative weights are easier to understand at a glance. However, RPG Treasure Tables map rather nicely to cumulative weights. The tables below have been constructed to have the exact same probabilities for each corresponding value.

Cumulative Weight Strategy

Note: Logic dictates Cumulative Weights must be unique!

from Fortuna import CumulativeWeightedChoice

cumulative_weighted_choice = CumulativeWeightedChoice((
    (7, "Apple"),
    (11, "Banana"),
    (13, "Cherry"),
    (23, "Grape"),
    (26, "Lime"),
    (30, "Orange"),
))
cumulative_weighted_choice()  # returns a weighted random value

Relative Weight Strategy

from Fortuna import RelativeWeightedChoice

relative_weighted_choice = RelativeWeightedChoice((
    (7, "Apple"),
    (4, "Banana"),
    (2, "Cherry"),
    (10, "Grape"),
    (3, "Lime"),
    (4, "Orange"),
))
relative_weighted_choice()  # returns a weighted random value

FlexCat

Controlled Chaos Incarnate
FlexCat wraps an OrderedDict of keyed sequences, and takes two optional keyword arguments, y_bias and x_bias. The Y axis keys are accessed directly at call time, or randomized with one of the QuantumMonty methods. The X axis sequences are randomized with one of the QuantumMonty methods.

By default FlexCat will use y_bias="front" and x_bias="cycle" if not specified at initialization. This will make the top of the data structure geometrically more common than the bottom, and it produces a flat cycled distribution for each category. FlexCat is short for flexible category sequence value generator.

Options for x & y bias: See QuantumMonty for details

  • front, geometric descending
  • middle, geometric pyramid
  • back, geometric ascending
  • first, gaussian descending
  • center, gaussian bell curve
  • last, gaussian ascending
  • flat, uniform flat
  • cycle, cycled uniform flat
  • monty, Quantum Monty Algorithm
from Fortuna import FlexCat
from collections import OrderedDict

flex_cat = FlexCat(
    OrderedDict({
        "Cat_A": ("A1", "A2", "A3", "A4", "A5"),
        "Cat_B": ("B1", "B2", "B3", "B4", "B5"),
        "Cat_C": ("C1", "C2", "C3", "C4", "C5"),
    }), y_bias="cycle", x_bias="cycle"
)
flex_cat("Cat_A")  # returns random value from "Cat_A" : cycled uniform distribution
flex_cat("Cat_B")  # returns random value from "Cat_B" : cycled uniform distribution
flex_cat("Cat_C")  # returns random value from "Cat_C" : cycled uniform distribution
flex_cat()         # returns random value from randomly cycled category : cycled uniform distribution

Fortuna Sample Distribution and Performance Test Suite

Testbed: MacOS 10.14.1, Python3.7, Quad 2.7GHz i7 Skylake, 16GB RAM, 1TB SSD

Random Numbers
-------------------------------------------------------------------------

Base Case:
random.randint(1, 10) x 10000: Total time: 15.0 ms, Average time: 1500.0 nano
 1: 10.7%
 2: 9.71%
 3: 10.07%
 4: 9.66%
 5: 9.87%
 6: 9.83%
 7: 10.38%
 8: 10.29%
 9: 9.67%
 10: 9.82%

random_range(1, 10) x 10000: Total time: 0.9 ms, Average time: 90.0 nano
 1: 9.92%
 2: 10.27%
 3: 9.69%
 4: 9.5%
 5: 9.96%
 6: 10.09%
 7: 9.94%
 8: 10.45%
 9: 9.98%
 10: 10.2%

Base Case:
random.randrange(10) x 10000: Total time: 9.75 ms, Average time: 975.0 nano
 0: 10.0%
 1: 9.84%
 2: 10.43%
 3: 9.99%
 4: 9.23%
 5: 9.9%
 6: 10.37%
 7: 9.84%
 8: 10.03%
 9: 10.37%

random_below(10) x 10000: Total time: 0.73 ms, Average time: 73.0 nano
 0: 10.25%
 1: 10.05%
 2: 9.76%
 3: 9.99%
 4: 9.84%
 5: 9.81%
 6: 9.94%
 7: 10.21%
 8: 10.33%
 9: 9.82%

d(10) x 10000: Total time: 0.73 ms, Average time: 73.0 nano
 1: 9.76%
 2: 9.81%
 3: 10.0%
 4: 9.91%
 5: 9.54%
 6: 10.23%
 7: 10.03%
 8: 10.47%
 9: 10.3%
 10: 9.95%

dice(2, 6) x 10000: Total time: 1.1 ms, Average time: 110.0 nano
 2: 2.55%
 3: 6.04%
 4: 8.71%
 5: 11.24%
 6: 13.87%
 7: 16.37%
 8: 13.62%
 9: 11.04%
 10: 8.48%
 11: 5.44%
 12: 2.64%

plus_or_minus(5) x 10000: Total time: 0.77 ms, Average time: 77.0 nano
 -5: 9.32%
 -4: 9.08%
 -3: 9.2%
 -2: 9.53%
 -1: 9.13%
 0: 8.55%
 1: 8.45%
 2: 9.8%
 3: 8.81%
 4: 9.16%
 5: 8.97%

plus_or_minus_linear(5) x 10000: Total time: 1.2 ms, Average time: 120.0 nano
 -5: 2.59%
 -4: 5.29%
 -3: 8.4%
 -2: 10.99%
 -1: 13.99%
 0: 16.46%
 1: 14.8%
 2: 10.55%
 3: 8.28%
 4: 5.75%
 5: 2.9%

plus_or_minus_curve(5) x 10000: Total time: 1.31 ms, Average time: 131.0 nano
 -5: 0.2%
 -4: 1.0%
 -3: 4.4%
 -2: 11.09%
 -1: 20.55%
 0: 24.16%
 1: 21.06%
 2: 11.65%
 3: 4.43%
 4: 1.2%
 5: 0.26%

zero_flat(10) x 10000: Total time: 0.74 ms, Average time: 74.0 nano
 0: 8.94%
 1: 9.13%
 2: 8.95%
 3: 9.01%
 4: 9.0%
 5: 9.14%
 6: 9.13%
 7: 8.85%
 8: 9.36%
 9: 9.14%
 10: 9.35%

zero_cool(10) x 10000: Total time: 1.85 ms, Average time: 185.0 nano
 0: 16.37%
 1: 15.23%
 2: 13.61%
 3: 12.39%
 4: 10.14%
 5: 9.06%
 6: 7.81%
 7: 6.11%
 8: 4.83%
 9: 2.88%
 10: 1.57%

zero_extreme(10) x 10000: Total time: 1.86 ms, Average time: 186.0 nano
 0: 22.35%
 1: 20.82%
 2: 17.92%
 3: 14.13%
 4: 10.95%
 5: 6.03%
 6: 4.21%
 7: 1.93%
 8: 1.08%
 9: 0.44%
 10: 0.14%

max_cool(10) x 10000: Total time: 1.88 ms, Average time: 188.0 nano
 0: 1.56%
 1: 2.98%
 2: 4.49%
 3: 5.86%
 4: 7.37%
 5: 9.4%
 6: 10.77%
 7: 12.03%
 8: 13.87%
 9: 15.2%
 10: 16.47%

max_extreme(10) x 10000: Total time: 2.04 ms, Average time: 204.0 nano
 0: 0.2%
 1: 0.41%
 2: 1.05%
 3: 1.79%
 4: 4.01%
 5: 6.47%
 6: 10.37%
 7: 14.37%
 8: 18.82%
 9: 20.88%
 10: 21.63%

mostly_middle(10) x 10000: Total time: 1.01 ms, Average time: 101.0 nano
 0: 3.11%
 1: 5.55%
 2: 8.28%
 3: 11.27%
 4: 13.26%
 5: 16.92%
 6: 13.69%
 7: 11.16%
 8: 8.66%
 9: 5.28%
 10: 2.82%

mostly_center(10) x 10000: Total time: 1.3 ms, Average time: 130.0 nano
 0: 0.32%
 1: 1.07%
 2: 4.48%
 3: 11.4%
 4: 20.72%
 5: 24.15%
 6: 20.85%
 7: 11.28%
 8: 4.32%
 9: 1.18%
 10: 0.23%


Random Truth
-------------------------------------------------------------------------

percent_true(25) x 10000: Total time: 0.9 ms, Average time: 90.0 nano
 False: 74.93%
 True: 25.07%


Random Values from a Sequence
-------------------------------------------------------------------------

some_list = ('Alpha', 'Beta', 'Delta', 'Eta', 'Gamma', 'Kappa', 'Zeta')

Base Case:
random.choice(some_list) x 10000: Total time: 7.63 ms, Average time: 763.0 nano
 Alpha: 14.78%
 Beta: 14.46%
 Delta: 14.13%
 Eta: 14.58%
 Gamma: 14.05%
 Kappa: 14.24%
 Zeta: 13.76%

random_value(some_list) x 10000: Total time: 0.78 ms, Average time: 78.0 nano
 Alpha: 14.09%
 Beta: 15.06%
 Delta: 13.63%
 Eta: 14.2%
 Gamma: 14.44%
 Kappa: 14.21%
 Zeta: 14.37%

monty = QuantumMonty(some_list)

monty.mostly_front() x 10000: Total time: 2.23 ms, Average time: 223.0 nano
 Alpha: 24.55%
 Beta: 22.42%
 Delta: 17.9%
 Eta: 14.66%
 Gamma: 10.36%
 Kappa: 6.71%
 Zeta: 3.4%

monty.mostly_middle() x 10000: Total time: 1.56 ms, Average time: 156.0 nano
 Alpha: 5.89%
 Beta: 12.04%
 Delta: 18.69%
 Eta: 25.27%
 Gamma: 19.18%
 Kappa: 12.42%
 Zeta: 6.51%

monty.mostly_back() x 10000: Total time: 2.13 ms, Average time: 213.0 nano
 Alpha: 3.29%
 Beta: 7.04%
 Delta: 10.44%
 Eta: 13.87%
 Gamma: 18.78%
 Kappa: 21.61%
 Zeta: 24.97%

monty.mostly_first() x 10000: Total time: 2.45 ms, Average time: 245.0 nano
 Alpha: 34.13%
 Beta: 29.74%
 Delta: 20.28%
 Eta: 10.2%
 Gamma: 4.27%
 Kappa: 1.12%
 Zeta: 0.26%

monty.mostly_center() x 10000: Total time: 1.99 ms, Average time: 199.0 nano
 Alpha: 0.48%
 Beta: 4.84%
 Delta: 24.06%
 Eta: 39.91%
 Gamma: 24.39%
 Kappa: 5.87%
 Zeta: 0.45%

monty.mostly_last() x 10000: Total time: 2.42 ms, Average time: 242.0 nano
 Alpha: 0.25%
 Beta: 1.21%
 Delta: 3.88%
 Eta: 10.48%
 Gamma: 19.94%
 Kappa: 29.8%
 Zeta: 34.44%

monty.mostly_cycle() x 10000: Total time: 6.32 ms, Average time: 632.0 nano
 Alpha: 13.8%
 Beta: 14.51%
 Delta: 14.36%
 Eta: 14.24%
 Gamma: 14.45%
 Kappa: 14.16%
 Zeta: 14.48%

monty.mostly_flat() x 10000: Total time: 1.31 ms, Average time: 131.0 nano
 Alpha: 14.7%
 Beta: 14.12%
 Delta: 14.73%
 Eta: 13.61%
 Gamma: 14.53%
 Kappa: 13.91%
 Zeta: 14.4%

monty.quantum_monty() x 10000: Total time: 3.28 ms, Average time: 328.0 nano
 Alpha: 11.26%
 Beta: 12.92%
 Delta: 16.15%
 Eta: 18.6%
 Gamma: 16.19%
 Kappa: 12.97%
 Zeta: 11.91%

random_cycle = RandomCycle(some_list)

random_cycle() x 10000: Total time: 5.57 ms, Average time: 557.0 nano
 Alpha: 14.4%
 Beta: 14.51%
 Delta: 14.31%
 Eta: 13.97%
 Gamma: 14.19%
 Kappa: 14.27%
 Zeta: 14.35%


Random Values by Weighted Table
-------------------------------------------------------------------------

population = ('Apple', 'Banana', 'Cherry', 'Grape', 'Lime', 'Orange')
cum_weights = (7, 11, 13, 23, 26, 30)

Cumulative Base Case:
random.choices(pop, cum_weights=cum_weights) x 10000: Total time: 16.91 ms, Average time: 1691.0 nano
 Apple: 23.19%
 Banana: 12.85%
 Cherry: 6.5%
 Grape: 33.95%
 Lime: 10.16%
 Orange: 13.35%

weights = (7, 4, 2, 10, 3, 4)

Relative Base Case:
random.choices(pop, weights) x 10000: Total time: 21.26 ms, Average time: 2126.0 nano
 Apple: 23.11%
 Banana: 12.95%
 Cherry: 7.08%
 Grape: 33.49%
 Lime: 10.07%
 Orange: 13.3%

cumulative_table = ((7, 'Apple'), (11, 'Banana'), (13, 'Cherry'), (23, 'Grape'), (26, 'Lime'), (30, 'Orange'))

Fortuna.cumulative_weighted_choice(cumulative_table) x 10000: Total time: 1.71 ms, Average time: 171.0 nano
 Apple: 23.84%
 Banana: 12.78%
 Cherry: 6.59%
 Grape: 33.33%
 Lime: 10.16%
 Orange: 13.3%

cumulative_choice = CumulativeWeightedChoice(cumulative_table)

cumulative_choice() x 10000: Total time: 2.58 ms, Average time: 258.0 nano
 Apple: 23.69%
 Banana: 13.52%
 Cherry: 6.94%
 Grape: 32.88%
 Lime: 9.52%
 Orange: 13.45%

relative_table = ((7, 'Apple'), (4, 'Banana'), (2, 'Cherry'), (10, 'Grape'), (3, 'Lime'), (4, 'Orange'))
relative_choice = RelativeWeightedChoice(relative_table)

relative_choice() x 10000: Total time: 2.76 ms, Average time: 276.0 nano
 Apple: 22.85%
 Banana: 13.51%
 Cherry: 6.9%
 Grape: 33.45%
 Lime: 9.95%
 Orange: 13.34%


Random Values by Category
-------------------------------------------------------------------------

flex_cat = FlexCat(OrderedDict({
    "Cat_A": ("A1", "A2", "A3", "A4", "A5"),
    "Cat_B": ("B1", "B2", "B3", "B4", "B5"),
    "Cat_C": ("C1", "C2", "C3", "C4", "C5"),
}), y_bias="front", x_bias="flat")

flex_cat('Cat_A') x 10000: Total time: 2.77 ms, Average time: 277.0 nano
 A1: 20.22%
 A2: 19.36%
 A3: 19.84%
 A4: 20.75%
 A5: 19.83%

flex_cat('Cat_B') x 10000: Total time: 3.02 ms, Average time: 302.0 nano
 B1: 20.69%
 B2: 20.08%
 B3: 20.11%
 B4: 19.36%
 B5: 19.76%

flex_cat('Cat_C') x 10000: Total time: 3.25 ms, Average time: 325.0 nano
 C1: 19.71%
 C2: 20.01%
 C3: 19.82%
 C4: 20.21%
 C5: 20.25%

flex_cat() x 10000: Total time: 4.39 ms, Average time: 439.0 nano
 A1: 10.01%
 A2: 9.23%
 A3: 9.79%
 A4: 10.82%
 A5: 9.84%
 B1: 5.96%
 B2: 6.64%
 B3: 6.22%
 B4: 7.15%
 B5: 6.75%
 C1: 3.6%
 C2: 3.75%
 C3: 3.57%
 C4: 3.31%
 C5: 3.36%


-------------------------------------------------------------------------
Total Test Time: 0.2 sec

Fortuna Beta Development Log

Fortuna 0.18.5
Updated documentation.
Fixed another minor test bug. \

Fortuna 0.18.4
Updated documentation to reflect recent changes.
Fixed some small test bugs.
Reduced default number of test cycles to 10,000 - down from 100,000.

Fortuna 0.18.3
Fixed some minor README typos.

Fortuna 0.18.2
Fixed a bug with Fortuna Pure.

Fortuna 0.18.1
Fixed some minor typos.
Added tests to Fortuna Pure.

Fortuna 0.18.0
Introduced new test format, now includes average call time in nanoseconds.
Reduced default number of test cycles to 100,000 - down from 1,000,000.
Added pure Python implementation of Fortuna: .../fortuna_extras/fortuna_pure.py
Promoted several low level functions to top level.

  • zero_flat(num: int) -> int
  • zero_cool(num: int) -> int
  • zero_extreme(num: int) -> int
  • max_cool(num: int) -> int
  • max_extreme(num: int) -> int
  • analytic_continuation(func: staticmethod, num: int) -> int
  • min_max(num: int, lo: int, hi: int) -> int

Fortuna 0.17.3
Internal development cycle.

Fortuna 0.17.2
User Requested: dice() and d() functions now support negative numbers as input.

Fortuna 0.17.1
Fixed some minor typos.

Fortuna 0.17.0
Added QuantumMonty to replace Mostly, same default behavior with more options.
Mostly is depreciated and may be removed in a future release.
Added FlexCat to replace MultiCat, same default behavior with more options.
MultiCat is depreciated and may be removed in a future release.
Expanded the Treasure Table example in .../fortuna_extras/fortuna_examples.py

Fortuna 0.16.2
Minor refactoring for WeightedChoice

Fortuna 0.16.1
Redesigned fortuna_examples.py to feature a dynamic random magic item generator.
Raised cumulative_weighted_choice function to top level.
Added test for cumulative_weighted_choice as free function.
Updated MultiCat documentation for clarity.

Fortuna 0.16.0
Pushed distribution_timer to the .pyx layer.
Changed default number of iterations of tests to 1 million, up form 1 hundred thousand.
Reordered tests to better match documentation.
Added Base Case Fortuna.fast_rand_below. Added Base Case Fortuna.fast_d.
Added Base Case Fortuna.fast_dice.

Fortuna 0.15.10
Internal Development Cycle

Fortuna 0.15.9
Added Base Cases for random.choices
Added Base Case for randint_dice

Fortuna 0.15.8
Clarified MultiCat Test

Fortuna 0.15.7
Fixed minor typos.

Fortuna 0.15.6
Fixed minor typos.
Simplified MultiCat example.

Fortuna 0.15.5
Added MultiCat test.
Fixed some minor typos in docs.

Fortuna 0.15.4
Performance optimization for both WeightedChoice() variants.
Cython update provides small performance enhancement across the board.
Compilation now leverages Python3 all the way down.
MultiCat pushed to the .pyx layer for better performance.

Fortuna 0.15.3
Reworked the MultiCat example to include several randomizing strategies working in concert.
Added Multi Dice 10d10 performance tests.
Updated sudo code in documentation to be more pythonic.

Fortuna 0.15.2
Fixed: Linux installation failure.
Added: complete source files to the distribution (.cpp .hpp .pyx).

Fortuna 0.15.1
Updated & simplified distribution_timer in fortuna_tests.py
Readme updated, fixed some typos.
Known issue preventing successful installation on some linux platforms.

Fortuna 0.15.0
Performance tweaks. \ Readme updated, added some details.

Fortuna 0.14.1
Readme updated, fixed some typos.

Fortuna 0.14.0
Fixed a bug where the analytic continuation algorithm caused a rare issue during compilation on some platforms.

Fortuna 0.13.3
Fixed Test Bug: percent sign was missing in output distributions.
Readme updated: added update history, fixed some typos.

Fortuna 0.13.2
Readme updated for even more clarity.

Fortuna 0.13.1
Readme updated for clarity.

Fortuna 0.13.0
Minor Bug Fixes.
Readme updated for aesthetics.
Added Tests: .../fortuna_extras/fortuna_tests.py

Fortuna 0.12.0
Internal test for future update.

Fortuna 0.11.0
Initial Release: Public Beta

Fortuna 0.10.0
Module name changed from Dice to Fortuna

Legal Stuff

Fortuna :: Copyright (c) 2018 Broken aka Robert W. Sharp

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

This README.md file shall be included in all copies or portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Fortuna-0.18.5.tar.gz (119.5 kB view hashes)

Uploaded Source

Built Distribution

Fortuna-0.18.5-cp37-cp37m-macosx_10_9_x86_64.whl (113.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page