Commit 615a8c05 authored by Adam P. Goucher's avatar Adam P. Goucher
Browse files

Functionality to check infile.mc and outfile.mc

parent 0a0ddf71
Pipeline #37783117 passed with stages
in 6 minutes and 44 seconds
......@@ -17,3 +17,4 @@ staging:
stage: staging
script:
- bash slsparse.cpp
- python check.py
import lifelib
from sys import argv
infile = 'infile.mc' if (len(argv) <= 1) else argv[1]
outfile = 'outfile.mc' if (len(argv) <= 2) else argv[2]
sess = lifelib.load_rules('b3s23')
lt = sess.lifetree(n_layers=1)
def run_to_completion(pat):
bb = pat.bounding_box
x = 4 * (bb[2] + bb[3])
x -= (x % 4096)
x += 6144
return pat[x]
print("Loading patterns...")
a = lt.load('infile.mc')
b = lt.load('outfile.mc')
print("Replacing objects...")
# Replace block-on-mango with block:
findme = lt.pattern("6$4bo$3bobob2o$2bo2bob2o$2bobo$3bo!", "b3s23")
replaceme = lt.pattern("7$7b2o$7b2o!", "b3s23")
a = a.replace(findme, replaceme, orientations='rotate4reflect')
# Replace PS4B with empty space:
findme = lt.pattern("3b2o$2bo2bo$bob2obo$obo2bobo$obo2bobo$bob2obo$2bo2bo$3b2o!", "b3s23")
replaceme = lt.pattern("", "b3s23")
a = a.replace(findme, replaceme, orientations='rotate4reflect')
print("Running to completion...")
a = run_to_completion(a)
b = run_to_completion(b)
print("Populations and bounding boxes:")
print(a.population)
print(b.population)
print(a.bounding_box)
print(b.bounding_box)
if (a.population != b.population):
raise ValueError("Populations do not match")
if (a.bounding_box != b.bounding_box):
raise ValueError("Bounding boxes do not match")
if (a != b):
raise ValueError("Patterns do not match")
print("Input and output files are consistent")
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