• Stars
    star
    175
  • Rank 216,743 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python Library for Conway's Game of Life

A Python library for Conway's Game of Life

This framework allows you to create and simulate various artificial lifeforms and cellular automata easily: simply define your board, add your lifeforms, and execute the run command! It also provides a myriad of pre-made lifeforms while allowing you to create your own.

Why name it Seagull? Conway's Game of Life is quite a mouthful, so I just refer to its acronym, CGoL. The word "seagull" is just a pun of that.

Simulate your first lifeforms in few lines of code:

import seagull as sg
from seagull.lifeforms import Pulsar

# Initialize board
board = sg.Board(size=(19,60))  

# Add three Pulsar lifeforms in various locations
board.add(Pulsar(), loc=(1,1))
board.add(Pulsar(), loc=(1,22))
board.add(Pulsar(), loc=(1,42))

# Simulate board
sim = sg.Simulator(board)      
sim.run(sg.rules.conway_classic, iters=1000)

Optionally, you can animate the simulation by running sim.animate():

Aside from Pulsar, we have a nice collection of lifeforms for you to choose from!

Installation

To install Seagull, run this command in your terminal:

pip install pyseagull

This is the preferred method to install Seagull, as it will always install the most recent stable release.

In case you want to install the bleeding-edge version, clone this repo:

git clone https://github.com/ljvmiranda921/seagull.git

and then run

cd seagull
python setup.py install

Usage

There are three main components for an artificial life simulation:

  • The Board or the environment in which the lifeforms will move around
  • The Lifeform that will interact with the environment, and
  • The rules that dictate if a particular cell will survive or not

In Seagull, you simply define your Board, add your Lifeform/s, and run the Simulator given a rule. You can add multiple lifeforms as you want:

import seagull as sg
from seagull import lifeforms as lf

board = sg.Board(size=(30,30))
board.add(lf.Blinker(length=3), loc=(4,4))
board.add(lf.Glider(), loc=(10,4))
board.add(lf.Glider(), loc=(15,4))
board.add(lf.Pulsar(), loc=(5,12))
board.view()  # View the current state of the board

Then you can simply run the simulation, and animate it when needed:

sim = sg.Simulator(board)
hist = sim.run(sg.rules.conway_classic, iters=1000)  # Save simulation history
sim.animate()

Adding custom lifeforms

You can manually create your lifeforms by using the Custom class:

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]]), loc=(0,0))

Obtaining simulation statistics and history

By default, the simulation statistics will always be returned after calling the run() method. In addition, you can also obtain the history by calling the get_history() method.

# The run() command returns the run statistics
stats = sim.run(sg.rules.conway_classic, iters=1000)
# You can also get it using get_history()
hist = sim.get_history()

Examples

You can find more examples in the documentation

Contributing

This project is open for contributors! Contibutions can come in the form of feature requests, bug fixes, documentation, tutorials and the like! We highly recommend to file an Issue first before submitting a Pull Request.

Simply fork this repository and make a Pull Request! We'd definitely appreciate:

  • Implementation of new features
  • Bug Reports
  • Documentation
  • Testing

License

MIT License (c) 2019, Lester James V. Miranda

More Repositories

1

pyswarms

A research toolkit for particle swarm optimization in Python
Python
1,258
star
2

sprites-as-a-service

Generate your personal 8-bit avatars using Cellular Automata, a mathematical model that simulates life, survival, and extinction
Vue
304
star
3

prodigy-pdf-custom-recipe

Custom recipe and utilities for document processing
Python
199
star
4

ljvmiranda921.github.io

✨ Github repository for my website
HTML
62
star
5

gym-lattice

An HP 2D Lattice Environment with a Gym-like API for the Protein Folding Problem
Python
54
star
6

calamanCy

NLP pipelines for Tagalog using spaCy
Python
41
star
7

burnout-barometer

A simple Slack tool to log, track, and assess you or your team's stress and work-life
Go
32
star
8

vs-split

A Python library for creating adversarial splits
Python
13
star
9

cv

Curriculum vitae of Lester James V. Miranda
TeX
10
star
10

abyss

Descend into the abyss | A retro action-roguelike game
GDScript
6
star
11

dataflow-cookiecutter

Create production-ready Dataflow projects in a zap! âš¡
Python
5
star
12

spacy-span-analyzer

Simple tool to analyze spans in your dataset. Implementation of Papay et al's work (EMNLP 2020) on span performance prediction
Python
5
star
13

scratch

📓 Scratch notebooks and random assortment of projects. Think of this as a scratch paper of my ideas.
Jupyter Notebook
5
star
14

gallery

📷 Gallery for Gameboy Camera
HTML
3
star
15

LiBERTus

Multilingual BERT model for Ancient and Historical Languages for SIGTYP Shared Task 2024
Python
3
star
16

ud-tagalog-spacy

Training a POS Tagger and Dependency Parser for a Low-Resource Language (Tagalog)
Python
2
star
17

comments.ljvmiranda921.github.io

Blog comments for my personal blog: ljvmiranda921.github.io
1
star
18

pfn-rl-practice

My solutions to the 2017 PFN Intern Coding exercise in Reinforcement Learning
Python
1
star