scamp_extensions.process.l_systems.LSystem

class scamp_extensions.process.l_systems.LSystem(seed_string: str, production_rules: MutableMapping[str, str], meanings: Optional[MutableMapping[str, Any]] = None)[source]

Bases: object

Simple implementation of an LSystem. Each generation is a string consisting of an alphabet of characters. Optionally, these characters can be assigned meanings.

Parameters:
  • seed_string – the initial string

  • production_rules – dictionary describing how each letter evolves in a subsequent generation. Any letter not found in the dictionary is assumed to be a constant. Also, stochastic rules are possible by providing a list or tuple of outcomes for a given letter, or a list/tuple consisting of a list of outcomes and a list of weightings.

  • meanings – (optional) dictionary specifying the meaning of each letter. Should contain an entry for every letter potentially encountered.

Variables:
  • seed – the initial string

  • rules – dictionary describing how each letter evolves in a subsequent generation. Any letter not found in the dictionary is assumed to be a constant

  • meanings – (optional) dictionary specifying the meaning of each letter. Should contain an entry for every letter potentially encountered.

Methods

get_generation(n)

Get the state of the system at the nth generation of iteration, where n=0 is the initial state.

get_generation_meanings(n)

Get the meanings associated with the given generation, according to the meanings dictionary.

get_generation(n: int) str[source]

Get the state of the system at the nth generation of iteration, where n=0 is the initial state. The first time a generation is requested, all previous generations must be processed; however, thereafter they are cached.

Parameters:

n – which generation

get_generation_meanings(n: int) Tuple[source]

Get the meanings associated with the given generation, according to the meanings dictionary.

Parameters:

n – which generation