NAME
Algorithm::Gutter::Cell - cellular automata to simulate rain in a gutter
DESCRIPTION
This module provides cells that can populate a Algorithm::Gutter gutter array reference, or the caller could instead provide their own object that conforms to the same interface as this module.
Cells may contain some amount of fluid, may have a hole in them that drains some amount of the fluid at some threshold, and the hole may or may not be enabled. An update code reference should be supplied that will trigger when fluid drains from the cell.
FIELDS
Note that mutator methods must be written as <$cell-
enabled = 1>> and not <$cell-
enabled(1)>>.
- amount
-
Mutator for the amount of fluid present in the cell, by default
0
. - context
-
Mutator for a user-supplied scalar that can contain additional state for the cell.
- enabled
-
Mutator for whether the cell's hole is enabled, or not. Cells are not enabled by default.
- id
-
Reader for a user-supplied ID (
0
by default) for the object. Could be set to the gutter array index to help track down where an otherwise unknown cell reference lives. - threshold
-
Mutator for the threshold at which the cell drains, by default a very large integer. Cells with actual holes in them should probably set the threshold to a much smaller non-negative integer value. And one may also want to sometimes enable the cell so that it can drain.
- update
-
Mutator for a code reference that will be called when the drain method in Algorithm::Gutter calculates that this cell's fluid drains. The reference is called with the cell object, cell index in the gutter list, how much fluid drained, and an optional stash provided by the caller.
The caller is responsible for the return value, which will be accumulated by the parent drain method and returned to the caller as a list. For example, the update code could return MIDI events, the amount of fluid drained, both, neither, or other values as need be.
Failing to set an update callback for a cell that triggers will result in an exception.
METHODS
BUGS
These probably should be called errors, not bugs.
SEE ALSO
AUTHOR
Jeremy Mates
COPYRIGHT AND LICENSE
Copyright (C) 2024 by Jeremy Mates
This module is distributed under the (Revised) BSD License.