Lifeforms¶
Lifeforms represent the evolving patterns whenever a rule is applied. In Seagull, lifeforms are first-class citizens: you can add them to the board, view them independently, compose, customize, and the like. This library provides a collection of pre-made lifeforms that you can play around.
Lifeforms are arranged into categories based on their configurations (excluding the Base and Custom lifeforms):
Gliders are lifeforms that oscillate but move while oscillating |
|
Growers are lifeforms that exhibit asymptotically unbounded growth |
|
Oscillators are lifeforms that returns to its initial configuration after some time |
|
|
Methuselahs are long-lived lifeforms which evolve rapidly before reaching a steady state after many cycles. |
Random lifeforms are generated on-the-fly without specific configuration |
|
Static lifeforms do not oscillate nor move given classic Conway rules |
Base¶
Base class for all Lifeform implementations. All lifeforms found in this
library inherits from the seagull.lifeforms.base.Lifeform
class. You can
use this to implement your own lifeforms or contributing new lifeforms to
Seagull:
class MyNewLifeform(Lifeform): def __init__(self, arg1=1, arg2=2): super(MyNewLifeform, self).__init__() self.arg1 = arg1 self.arg2 = arg2 @property def layout(self) -> np.ndarray: return np.array([[0, 0, 1, 1]])
When contributing your new lifeform, we highly-recommend to set sensible
defaults when initializing it. This is because the current test running simply
runs the inspect
module to get all classes and run the same set of
tests.
If you wish to pass a custom lifeform to the board, I recommend using the
seagull.lifeforms.custom.Custom
class.
Custom¶
The Custom lifeform allows you to easily pass any arbitrary array as a
seagull.lifeforms.base.Lifeform
to the Board. However, it is important
that the array passes two conditions:
It must be a 2-dimensional array. For lines such as Blinkers, we often use an array of shape
(2, 1)
.It must be a binary array where
True
represents active cells andFalse
for inactive cells. You can also use 0s and 1s as input.
If any of these conditions aren’t fulfilled, then Seagull will raise a
ValueError
Here’s an example in creating a custom lifeform:
import seagull as sg from seagull.lifeforms import Custom board = sg.Board(size=(30,30)) board.add(Custom([[0,1,1,0], [0,0,1,1]]))
All Lifeforms¶
This section contains all lifeforms currently implemented in the library. It is not yet comprehensive, so it would be really nice if you can help me add more!
Gliders¶
Gliders are lifeforms that oscillate but move while oscillating
|
Growers¶
Growers are lifeforms that exhibit asymptotically unbounded growth
|
A lifeform with asymptotically unbounded growth |
Oscillators¶
Oscillators are lifeforms that returns to its initial configuration after some time
|
A horizontal Blinker lifeform |
|
A Toad lifeform oscillator |
|
A Pulsar lifeform oscillator |
Random¶
Random lifeforms are generated on-the-fly without specific configuration
|
A random box with arbitrarily-set shape |
Static¶
Static lifeforms do not oscillate nor move given classic Conway rules
|
A static Box |
|
A static Seed |
|
A static Moon |
|
A static Kite |