API for the emul module of formform.
cellular automaton
→ system that iteratively produces the next generation
evolution
→ causal chain of generations
generation
→ state in an evolution
→ n-dimensional relation between cells
cell
→ system that indicates a calc/value
ini {sys-ini}
→ initial generation of the cellular automaton
→ configuration of cells by a pattern
umwelt
→ arrangement of cells observable from/by the cell
→ environment for rule application
rule {sys-next}
→ function to determine the next state of the cell
→ correspondence between umwelt / self (→Cell) and calc/value
API for the `emul` module of `formform`.
## Concepts
### Cellular Automata
**cellular automaton**
→ system that _iteratively_ produces the next _generation_
* _automaton_ → model for the description of _rule_-based _state_ changes
* _iteration_ → reproduce the operation
* _state_ → correspondence between time and _value_ of the system
**evolution**
→ causal chain of _generations_
**generation**
→ _state_ in an _evolution_
→ n-dimensional relation between _cells_
**cell**
→ system that indicates a _calc/value_
### Specification
**ini {sys-ini}**
→ initial _generation_ of the _cellular automaton_
→ _configuration_ of _cells_ by a pattern
* _configuration_ → _arrangement_ by a perspective
* _arrangement_ → selection in space
**umwelt**
→ _arrangement_ of _cells_ observable from/by the _cell_
→ environment for _rule_ application
**rule {sys-next}**
→ function to determine the next _state_ of the _cell_
→ correspondence between _umwelt_ / self _(→Cell)_ and _calc/value_
All registered ini/umwelt/rule types.
All registered ini/umwelt/rule types.
(apply-rule rule-spec umwelt cell)Returns a cell value given a rule-spec (via make-rule), an umwelt (via observe-umwelt) and the current cell (a vector of the shape [[x ?y] value]).
Returns a cell value given a `rule-spec` (via [[make-rule]]), an `umwelt` (via [[observe-umwelt]]) and the current `cell` (a vector of the shape `[[x ?y] value]`).
(ca-iterator ca-spec resolution)(ca-iterator ca-spec resolution steps)Returns a lazy seq that iteratively computes the next generation for the given a ca-spec (cellular automaton specification, via specify-ca, etc.) and a resolution vector.
Optionally, the last argument can be a number to just get the first n steps in its evolution.
Returns a lazy seq that iteratively computes the next generation for the given a `ca-spec` (cellular automaton specification, via [[specify-ca]], etc.) and a `resolution` vector. Optionally, the last argument can be a number to just get the first _n_ `steps` in its evolution.
Map of common specimen to specify cellular automata. Contains all the SelFis introduced by Ralf Peyn in ‘uFORM iFORM’.
Map of common specimen to specify cellular automata. Contains all the SelFis introduced by Ralf Peyn in ‘uFORM iFORM’.
(create-ca ca-spec resolution)(create-ca ca-spec resolution history-cache-limit)Returns a stateful CellularAutomaton object for the given ca-spec (cellular automaton specification, via specify-ca, etc.) and a resolution vector.
May take an optional history-cache-limit to manually set the limit for how many generations will be cached (otherwise an heuristic algorithm is used).
Callable methods are step, restart, get-resolution, get-current-generation, get-cached-history, get-system-time and get-history-cache-limit (see docs for further explanation).
Returns a stateful `CellularAutomaton` object for the given `ca-spec` (cellular automaton specification, via [[specify-ca]], etc.) and a `resolution` vector. May take an optional `history-cache-limit` to manually set the limit for how many generations will be cached (otherwise an heuristic algorithm is used). Callable methods are `step`, `restart`, `get-resolution`, `get-current-generation`, `get-cached-history`, `get-system-time` and `get-history-cache-limit` (see docs for further explanation).
(defini type-k fields doc-string? & methods)Defines a new type of ini pattern, to be specified with make-ini.
Takes a keyword identifier (type-k), fields for data the user needs to provide, an optional doc-string? (to describe the fields and the pattern) and one or more implementations of:
(make-gen [this opts w] …) for a 1D pattern(make-gen [this opts w h] …) for a 2D patternopts is an options map that can have keys such as :seed.Defines a new type of ini pattern, to be specified with [[make-ini]]. Takes a keyword identifier (`type-k`), `fields` for data the user needs to provide, an optional `doc-string?` (to describe the fields and the pattern) and one or more implementations of: * `(make-gen [this opts w] …)` for a 1D pattern * `(make-gen [this opts w h] …)` for a 2D pattern * `opts` is an options map that can have keys such as `:seed`.
(defrule type-k fields doc-string? & methods)Defines a new type of rule pattern, to be specified with make-rule.
Takes a keyword identifier (type-k), fields for data the user needs to provide, an optional doc-string? (to describe the fields and the pattern) and one or more implementations of:
(apply-rule [this umwelt self-v] …)umwelt is an ‘umwelt’ as provided by observe-umweltself-v is the value of the currently selected cellDefines a new type of rule pattern, to be specified with [[make-rule]]. Takes a keyword identifier (`type-k`), `fields` for data the user needs to provide, an optional `doc-string?` (to describe the fields and the pattern) and one or more implementations of: * `(apply-rule [this umwelt self-v] …)` * `umwelt` is an ‘umwelt’ as provided by [[observe-umwelt]] * `self-v` is the value of the currently selected cell
(defumwelt type-k fields doc-string? & methods)Defines a new type of umwelt pattern, to be specified with make-umwelt.
Takes a keyword identifier (type-k), fields for data the user needs to provide, an optional doc-string? (to describe the fields and the pattern) and one or more implementations of:
(observe-umwelt [this gen1d cell w] …) for a 1D pattern(observe-umwelt [this gen2d cell w h] …) for a 2D patterngen1d/gen2d is a vector of the current generation (flat in 1D, nested in 2D)cell is a vector [[x …] v] of the current cell coordinates and valueDefines a new type of umwelt pattern, to be specified with [[make-umwelt]]. Takes a keyword identifier (`type-k`), `fields` for data the user needs to provide, an optional `doc-string?` (to describe the fields and the pattern) and one or more implementations of: * `(observe-umwelt [this gen1d cell w] …)` for a 1D pattern * `(observe-umwelt [this gen2d cell w h] …)` for a 2D pattern * `gen1d`/`gen2d` is a vector of the current generation (flat in 1D, nested in 2D) * `cell` is a vector `[[x …] v]` of the current cell coordinates and value
(get-cached-history ca-obj)(get-cached-history ca-obj {:keys [optimized?] :or {optimized? false}})Given a stateful ca-object (of type CellularAutomaton), returns its cached history/evolution, where all generations are either vectors or native arrays (if optimized? is true).
Given a stateful `ca-object` (of type `CellularAutomaton`), returns its cached history/evolution, where all generations are either vectors or native arrays (if `optimized?` is true).
(get-current-generation ca-obj)(get-current-generation ca-obj {:keys [optimized?] :or {optimized? false}})Given a stateful ca-object (of type CellularAutomaton), returns its current generation either as a vector or a native array (if optimized? is true).
Given a stateful `ca-object` (of type `CellularAutomaton`), returns its current generation either as a vector or a native array (if `optimized?` is true).
(get-history-cache-limit ca-obj)Given a stateful ca-object (of type CellularAutomaton), returns the max. number of generations it caches (stored in its history).
Given a stateful `ca-object` (of type `CellularAutomaton`), returns the max. number of generations it caches (stored in its history).
(get-resolution ca-obj)Given a stateful ca-object (of type CellularAutomaton), returns its resolution.
Given a stateful `ca-object` (of type `CellularAutomaton`), returns its resolution.
(get-system-time ca-obj)Given a stateful ca-object (of type CellularAutomaton), returns its generation index (aka “system-time”).
Given a stateful `ca-object` (of type `CellularAutomaton`), returns its generation index (aka “system-time”).
A collection of predefined patterns for use with :figure inis.
A collection of predefined patterns for use with `:figure` inis.
(make-decisionform dna initial-size)(make-decisionform dna initial-size {:keys [overwrites ini-opts]})Returns a 2D cellular automaton known as a “decisionFORM” given a dna for its rule function and an initial-size for its ini (type :rand-figure).
The last argument can be an options map with keys:
:overwrites → a map to overwrite any part of the returned CA specReturns a 2D cellular automaton known as a “decisionFORM” given a `dna` for its rule function and an `initial-size` for its ini (type `:rand-figure`). The last argument can be an options map with keys: * `:overwrites` → a map to overwrite any part of the returned CA spec
Creates an instance of a CA ini (initial conditions) specification of a given type (as a keyword) and with given parameters as required by the type.
(make-ini :help) prints a list of all ini types and their parameters(make-ini :t :help) prints the parameters and docs for given type :tCreates an instance of a CA ini (initial conditions) specification of a given type (as a keyword) and with given parameters as required by the type. * `(make-ini :help)` prints a list of all ini types and their parameters * `(make-ini :t :help)` prints the parameters and docs for given type `:t`
(make-lifeform dna)(make-lifeform dna {:keys [overwrites ini-opts]})Returns a 2D cellular automaton known as a “lifeFORM” given a dna for its rule function.
The last argument can be an options map with keys:
:overwrites → a map to overwrite any part of the returned CA specReturns a 2D cellular automaton known as a “lifeFORM” given a `dna` for its rule function. The last argument can be an options map with keys: * `:overwrites` → a map to overwrite any part of the returned CA spec
(make-mindform dna ini-spec)(make-mindform dna ini-spec {:keys [overwrites]})Returns a 2D cellular automaton known as a “mindFORM” given a dna for its rule function and an ini-spec (via make-ini).
The last argument can be an options map with keys:
:overwrites → a map to overwrite any part of the returned CA specReturns a 2D cellular automaton known as a “mindFORM” given a `dna` for its rule function and an `ini-spec` (via [[make-ini]]). The last argument can be an options map with keys: * `:overwrites` → a map to overwrite any part of the returned CA spec
Creates an instance of a CA rule specification of a given type (as a keyword) and with given parameters as required by the type.
(make-rule :help) prints a list of all rule types and their parameters(make-rule :t :help) prints the parameters and docs for given type :tCreates an instance of a CA rule specification of a given type (as a keyword) and with given parameters as required by the type. * `(make-rule :help)` prints a list of all rule types and their parameters * `(make-rule :t :help)` prints the parameters and docs for given type `:t`
(make-selfi dna ini-spec)(make-selfi dna ini-spec {:keys [overwrites]})Returns a 1D cellular automaton known as a “SelFi” given a dna for its rule function and an ini-spec (via make-ini).
Its ‘umwelt’ is of type :select-ltr.
The last argument can be an options map with keys:
:overwrites → a map to overwrite any part of the returned CA specReturns a 1D cellular automaton known as a “SelFi” given a `dna` for its rule function and an `ini-spec` (via [[make-ini]]). Its ‘umwelt’ is of type `:select-ltr`. The last argument can be an options map with keys: * `:overwrites` → a map to overwrite any part of the returned CA spec
Creates an instance of a CA umwelt (neighborhood) specification of a given type (as a keyword) and with given parameters as required by the type.
(make-umwelt :help) prints a list of all umwelt types and their parameters(make-umwelt :t :help) prints the parameters and docs for given type :tCreates an instance of a CA umwelt (neighborhood) specification of a given type (as a keyword) and with given parameters as required by the type. * `(make-umwelt :help)` prints a list of all umwelt types and their parameters * `(make-umwelt :t :help)` prints the parameters and docs for given type `:t`
(observe-umwelt umwelt-spec generation cell)Returns an ‘umwelt’ given a umwelt-spec (via make-umwelt), a generation and the current cell (a vector of the shape [[x ?y] value]).
Returns an ‘umwelt’ given a `umwelt-spec` (via [[make-umwelt]]), a `generation` and the current `cell` (a vector of the shape `[[x ?y] value]`).
(restart ca-obj)Given a stateful ca-object (of type CellularAutomaton), resets its evolution to the initial generation.
Given a stateful `ca-object` (of type `CellularAutomaton`), resets its evolution to the initial generation.
(specify-ca specs-map)(specify-ca specs-map label)Returns a CASpec record, given a specs-map (which is a map of specifications for a custom cellular automaton) and an optional label.
The CASpec can be used with ca-iterator or create-ca. The input map needs to have all of the following entries:
:rule-spec: a rule specification as per make-rule:umwelt-spec: an umwelt specification as per make-umwelt:ini-spec: an ini specification as per make-iniNote that formform.emul has constructors for common ca specs via make-selfi, make-mindform, make-lifeform and make-decisionform. Furthermore, there are predefined ca specs in common-specimen.
Returns a `CASpec` record, given a `specs-map` (which is a map of specifications for a custom cellular automaton) and an optional `label`. The `CASpec` can be used with [[ca-iterator]] or [[create-ca]]. The input map needs to have all of the following entries: * `:rule-spec`: a rule specification as per [[make-rule]] * `:umwelt-spec`: an umwelt specification as per [[make-umwelt]] * `:ini-spec`: an ini specification as per [[make-ini]] Note that formform.emul has constructors for common ca specs via [[make-selfi]], [[make-mindform]], [[make-lifeform]] and [[make-decisionform]]. Furthermore, there are predefined ca specs in [[common-specimen]].
(step ca-object)Given a stateful ca-object (of type CellularAutomaton), computes its next generation and appends it to its evolution state.
Given a stateful `ca-object` (of type `CellularAutomaton`), computes its next generation and appends it to its evolution state.
(sys-ini ini-spec resolution)(sys-ini ini-spec resolution opts)Returns an (initial) generation given an ini-spec (via make-ini) and a resolution.
resolution must be a vector [width] (1D) or [width height] (2D).
The last argument can be an options map with keys:
:seed → an integer number to provide a seed for reproducable randomnessReturns an (initial) generation given an `ini-spec` (via [[make-ini]]) and a `resolution`. `resolution` must be a vector `[width]` (1D) or `[width height]` (2D). The last argument can be an options map with keys: * `:seed` → an integer number to provide a seed for reproducable randomness
(sys-next rule-spec umwelt-spec generation)Computes and returns the next generation given a rule-spec (via make-rule), an umwelt-spec (via make-umwelt) and a generation.
Computes and returns the next generation given a `rule-spec` (via [[make-rule]]), an `umwelt-spec` (via [[make-umwelt]]) and a `generation`.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |