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):

seagull.lifeforms.gliders

Gliders are lifeforms that oscillate but move while oscillating

seagull.lifeforms.growers

Growers are lifeforms that exhibit asymptotically unbounded growth

seagull.lifeforms.oscillators

Oscillators are lifeforms that returns to its initial configuration after some time

seagull.lifeforms.methuselahs

Methuselahs are long-lived lifeforms which evolve rapidly before reaching a steady state after many cycles.

seagull.lifeforms.random

Random lifeforms are generated on-the-fly without specific configuration

seagull.lifeforms.static

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.

class seagull.lifeforms.base.Lifeform[source]

Base class for all Lifeform implementation

abstract property layout

Lifeform layout or structure

Type

numpy.ndarray

Return type

ndarray

property size

Size of the lifeform

Type

tuple

Return type

Tuple[int, int]

view(figsize=(5, 5))[source]

View the lifeform

Returns

Graphical view of the lifeform

Return type

matplotlib.axes._subplots.AxesSubplot

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 and False 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]]))
class seagull.lifeforms.custom.Custom(X)[source]

Create custom lifeforms

__init__(X)[source]

Initialize the class

Parameters

X (array_like) – Custom binary array for the lifeform

property layout

Lifeform layout or structure

Type

numpy.ndarray

Return type

ndarray

validate_input_shapes(X)[source]

Check if input array is of size 2

validate_input_values(X)[source]

Check if all elements are binary

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

seagull.lifeforms.gliders.Glider()

Growers

Growers are lifeforms that exhibit asymptotically unbounded growth

seagull.lifeforms.growers.Unbounded()

A lifeform with asymptotically unbounded growth

Oscillators

Oscillators are lifeforms that returns to its initial configuration after some time

seagull.lifeforms.oscillators.Blinker([length])

A horizontal Blinker lifeform

seagull.lifeforms.oscillators.Toad()

A Toad lifeform oscillator

seagull.lifeforms.oscillators.Pulsar()

A Pulsar lifeform oscillator

Random

Random lifeforms are generated on-the-fly without specific configuration

seagull.lifeforms.random.RandomBox([shape, seed])

A random box with arbitrarily-set shape

Static

Static lifeforms do not oscillate nor move given classic Conway rules

seagull.lifeforms.static.Box()

A static Box

seagull.lifeforms.static.Seed()

A static Seed

seagull.lifeforms.static.Moon()

A static Moon

seagull.lifeforms.static.Kite()

A static Kite