beyarkay's picture
Lane re-export scripts and progress, window debugging scripts
0a3edb6 verified
Raw History Blame Contribute Delete
949 Bytes
import pickle, random, sys
import numpy as np, factorion_rs
import corpus.convert as cv
from factorion import render_factory, items
i, rows = sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "0:32"
a, b = map(int, rows.split(":"))
r, x0, y0 = pickle.load(open(f"../flow/dead_{i}.pkl", "rb"))
e = cv.edit(r, x0, y0, 32, random.Random(0)); w = cv.paste(r, x0, y0, 32, e)
print("\n".join(f"{y:2d} {l}" for y, l in enumerate(render_factory(w).split("\n")) if a <= y < b))
print([(x, y, "S" if k == cv._SOURCE else "K" if k == cv._SINK else k, d, items[it].name) for x, y, k, d, it in e if a <= y < b])
print("--- human layout with a 2-tile margin (window x/y = col/row - 1)")
full = cv.to_world(r)
H = full.shape[2]
sub = full[:, max(0, x0 - 3):x0 + 33, max(0, y0 - 3 + a):min(H, y0 + 1 + b)]
print(render_factory(sub))
print([(m[0], m[1] - x0 + 1, m[2] - y0 + 1) for m in r.masked if x0 - 3 <= m[1] <= x0 + 32 and y0 - 3 + a <= m[2] <= y0 + b][:20])