ljvmiranda921 / seagull

A Python Library for Conway's Game of Life
https://pyseagull.readthedocs.io/en/latest/index.html#
MIT License
174 stars 30 forks source link

Abstract how rules are defined #19

Closed ljvmiranda921 closed 4 years ago

ljvmiranda921 commented 5 years ago

I think it's possible to just define a class called Rule that takes in a rulestring and has classmethods that returns a callable. A sample usage may be the following:

import seagull as sg

rule = sg.Rule(B=3, S=[2,3])    # Simulates Conway's rule
rule.apply                                 # A callable that you apply to the board

Thus, the implementation of sg.rules.conway_classic may be as simple as returning the apply method.