2 releases
0.1.1 | May 31, 2023 |
---|---|
0.1.0 | May 28, 2023 |
#459 in Images
27 downloads per month
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 lenia_ca
crate is able to simulate.
The working principle for StandardLenia
is the following:
- Perform a convolution operation (implemented as a FFT-based convolution) between the
channel
andkernel
of theconvolution_channel
- Each point/pixel's value is then passed into a
growth_function
of theconvolution_channel
. - The resulting points/pixels are then multiplied by the integration step
dt
and added onto the original values in thechannel
. - The resulting points/pixels are then clamped to be in range
0..1
. This result is the next time-step of thechannel
, and would be used as the next iteration'schannel
values.
use set_kernel()
to change how the kernel looks.
use set_growth_function()
to set a specific growth function for the convolution result.
use set_dt()
to change the integration-step of the simulation.
The working principle for ExpandedLenia
is the following:
- For each
convolution_channel
, perform a convolution operation (implemented as a FFT-based convolution) between a sourcechannel
and theconvolution_channel
'skernel
. Notice how eachconvolution_channel
takes input from only onechannel
. - For each
convolution_channel
, pass the convolution results into thegrowth_function
of theconvolution_channel
. - For each
channel
, perform an elementwise multiplication between the correspondingconvolution_channel
results and weights of thechannel
- For each
channel
, perform a weighted-sum on the results of the weight-convolution multiplicated results. - For each
channel
, multiply the weighted-sum by the integration stepdt
and add it to the original values in thechannel
. - For each
channel
, clamp the resulting values to be in range0..1
. This result is the next time-step of the correspondingchannel
, and would be used as the next iteration'schannel
values.
use set_channels()
to set the number of channels in the simulation.
use set_convolution_channels()
to set the number of kernels and the associated growth functions.
use set_convolution_channel_source()
to set the channel which will be convoluted by a particular kernel.
use set_kernel()
to change how a convolution_channel
's kernel looks like.
use set_growth_function()
to set a specific growth function for the convolution result.
use set_weights()
to set a channel's weights for the corresponding convolution channel results.
use set_dt()
to change the integration-step of the simulation.
Dependencies
~6.5MB
~121K SLoC