Commit 862ffa56 authored by Adam P. Goucher's avatar Adam P. Goucher

Initial work on supporting genera

parent 1ee25a11
# This file defines the genera accepted by lifelib. Earlier genera take
# precedence over later genera, so (for example) the rule b3s23 belongs
# to the genus 'lifelike' rather than 'isotropic'.
genus_list = []
genus_list.append({'name': 'lifelike', 'regex': 'b0?1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'generations', 'regex': 'g[1-9][0-9]*b1?2?3?4?5?6?7?8?s0?1?2?3?4?5?6?7?8?'})
genus_list.append({'name': 'isotropic', 'regex': 'b[0-9ceaiknjqrytwz-]*s[0-9ceaiknjqrytwz-]*'})
genus_list.append({'name': 'ltl', 'regex': 'r[234567]b[1-9][0-9]*t[1-9][0-9]*s[1-9][0-9]*t[1-9][0-9]*'})
import re
def obtain_genus(rulestring):
for g in genus_list:
m = re.match(g['regex'] + '$', rulestring)
if m is not None:
return g['name']
raise ValueError('Rule "%s" does not belong to any genus' % rulestring)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment