mutwo.core_generators§

Classes and functions that generate data with the potential of artistic use.

The module is organised in different submodules where each submodule is named after the first known person who introduced the respective algorithms. Unlike the mutwo.converters module the entered data and the resulting data can be very different in type and form.

The term ‘generators’ simply labels the functionality of the module and shouldn’t be confused with the Python term for specific functions with the ‘yield’ keyword.

Object

Documentation

mutwo.core_generators.DynamicChoice

Weighted random choices with dynamically changing weights.

class DynamicChoice(value_sequence, curve_sequence, random_seed=100)[source]§

Weighted random choices with dynamically changing weights.

Parameters:
  • value_sequence (Sequence[Any]) – The items to choose from.

  • curve_sequence (Sequence[core_events.Envelope]) – The dynamically changing weight for each value.

  • random_seed (int) – The seed which shall be set at class initialisation.

Example:

>>> from mutwo import core_events
>>> from mutwo import core_generators
>>> dynamic_choice = core_generators.DynamicChoice(
>>>    [0, 1, 2],
>>>    [
>>>        core_events.Envelope([(0, 0), (0.5, 1), (1, 0)]),
>>>        core_events.Envelope([(0, 0.5), (0.5, 0), (1, 0.5)]),
>>>        core_events.Envelope([(0, 0.5), (1, 1)]),
>>>    ],
>>> )
>>> dynamic_choice.gamble_at(0.3)
2
>>> dynamic_choice.gamble_at(0.3)
2
>>> dynamic_choice.gamble_at(0.3)
0

Public Methods:

__init__(value_sequence, curve_sequence[, ...])

__repr__()

Return repr(self).

items()

gamble_at(time)

Return value at requested time.


gamble_at(time)[source]§

Return value at requested time.

Parameters:

time (numbers.Real) – At which position on the x-Axis shall be gambled.

Returns:

The chosen value.

Return type:

Any

items()[source]§
Return type:

tuple[tuple[Any, mutwo.core_events.envelopes.Envelope]]