Skip to content

Commit

Permalink
Add Beacon oscillator (#40)
Browse files Browse the repository at this point in the history
Reference: #33
  • Loading branch information
theodumont committed Apr 19, 2020
1 parent 61c2859 commit 8bad223
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion seagull/lifeforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""

from .static import Box, Seed, Moon, Kite
from .oscillators import Blinker, Toad, Pulsar, FigureEight
from .oscillators import Blinker, Toad, Pulsar, FigureEight, Beacon
from .gliders import Glider
from .growers import Unbounded
from .random import RandomBox
Expand All @@ -34,6 +34,7 @@
"Toad",
"Pulsar",
"FigureEight",
"Beacon",
"Glider",
"Unbounded",
"RandomBox",
Expand Down
15 changes: 15 additions & 0 deletions seagull/lifeforms/oscillators.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,18 @@ def layout(self) -> np.ndarray:
X[0:3, 0:3] = 1
X[3:6, 3:6] = 1
return X


class Beacon(Lifeform):
"""A Beacon lifeform oscillator"""

def __init__(self):
"""Initialize the class"""
super(Beacon, self).__init__()

@property
def layout(self) -> np.ndarray:
X = np.zeros((4, 4))
X[0:2, 0:2] = 1
X[2:4, 2:4] = 1
return X

0 comments on commit 8bad223

Please sign in to comment.