-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmake.py
43 lines (31 loc) · 826 Bytes
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
# Golly script for the pattern generation
import golly as g
import numpy as np
import pickle
def paste(g, fichier, x, y):
g.addlayer()
g.open(fichier)
g.select([-1000, -1000, 2000, 2000])
g.copy()
g.dellayer()
g.paste(x-1000,y-1000,'or')
def transfo(i,j):
return i*60-j*60, i*60+j*60
def load():
file = open("blocks.txt","r")
lines = file.read()
file.close()
lines = lines.split("\n")
blocks = [line.split() for line in lines][:-1]
blocks = [[line[0], int(line[1]), int(line[2])] for line in blocks]
return blocks
def make(blocks):
g.new("circuit")
for block in blocks:
fname = "blocks/{}.mc".format(block[0])
paste(g, fname, *transfo(block[1], block[2]))
g.fit()
g.save("circuit.mc", "mc")
blocks = load()
make(blocks)