File: EmulateOneDimensional.py

package info (click to toggle)
golly 3.2-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 19,516 kB
  • sloc: cpp: 69,819; ansic: 25,894; python: 7,921; sh: 4,267; objc: 3,721; java: 2,781; xml: 1,362; makefile: 530; perl: 69
file content (13 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
import os
from glife.RuleTree import *

def EmulateOneDimensional(neighborhood,n_states,transitions,input_filename):
    '''Emulate a oneDimensional neighborhood rule table with a vonNeumann neighborhood rule tree.'''
    rule_name = os.path.splitext(os.path.split(input_filename)[1])[0]
    tree = RuleTree(n_states,4)
    for t in transitions:
        tree.add_rule([t[0],range(n_states),t[2],t[1],range(n_states)],t[3][0]) # C,S,E,W,N,C'
    tree.write( golly.getdir('rules')+rule_name+".tree" )
    # use rule_name.tree to create rule_name.rule (no icon info)
    ConvertTreeToRule(rule_name, n_states, [])
    return rule_name