### 2 releases

0.1.1 | May 31, 2023 |
---|---|

0.1.0 | May 28, 2023 |

#**459** in Images

**27** downloads per month

**MIT**license

215KB

1.5K
SLoC

# lenia_ca

This crate has the core functionality for simulating the Lenia system of cellular automata. For more comprehensive documentation, please visit the docs.rs page for this crate.

At the time of publishing of this repository and crate, docs.rs does not allow embedding of images (not easily, anyways) in the documentation, and as a result, below are a few graphics viewable on Github showing the working principle of the two types of Lenia that the

crate is able to simulate.`lenia_ca`

### The working principle for `StandardLenia`

is the following:

`StandardLenia`

- Perform a convolution operation (implemented as a FFT-based convolution) between the

and`channel`

of the`kernel``convolution_channel` - Each point/pixel's value is then passed into a

of the`growth_function`

.`convolution_channel` - The resulting points/pixels are then multiplied by the integration step

and added onto the original values in the`dt`

.`channel` - The resulting points/pixels are then clamped to be in range

. This result is the next time-step of the`0``..``1`

, and would be used as the next iteration's`channel`

values.`channel`

use

to change how the kernel looks.`set_kernel``(``)`

use

to set a specific growth function for the convolution result.`set_growth_function``(``)`

use

to change the integration-step of the simulation.`set_dt``(``)`

### The working principle for `ExpandedLenia`

is the following:

`ExpandedLenia`

- For each

, perform a convolution operation (implemented as a FFT-based convolution) between a source`convolution_channel`

and the`channel`

's`convolution_channel`

. Notice how each`kernel`

takes input from only one`convolution_channel`

.`channel` - For each

, pass the convolution results into the`convolution_channel`

of the`growth_function`

.`convolution_channel` - For each

, perform an elementwise multiplication between the corresponding`channel`

results and weights of the`convolution_channel``channel` - For each

, perform a weighted-sum on the results of the weight-convolution multiplicated results.`channel` - For each

, multiply the weighted-sum by the integration step`channel`

and add it to the original values in the`dt`

.`channel` - For each

, clamp the resulting values to be in range`channel`

. This result is the next time-step of the corresponding`0``..``1`

, and would be used as the next iteration's`channel`

values.`channel`

use

to set the number of channels in the simulation.`set_channels``(``)`

use

to set the number of kernels and the associated growth functions.`set_convolution_channels``(``)`

use

to set the channel which will be convoluted by a particular kernel.`set_convolution_channel_source``(``)`

use

to change how a `set_kernel``(``)`

's kernel looks like.`convolution_channel`

use

to set a specific growth function for the convolution result.`set_growth_function``(``)`

use

to set a channel's weights for the corresponding convolution channel results.`set_weights``(``)`

use

to change the integration-step of the simulation.`set_dt``(``)`

#### Dependencies

~6.5MB

~121K SLoC