import glob, random, sys import numpy as np import corpus.convert as cv from functional import MACH, sample views = sample(sorted(glob.glob(sys.argv[1])), int(sys.argv[2]), nudge=True) for r, lab, *_ in views: r.lanes = {k: {getattr(cv.str2item(n), "value", -1) or -1 for n in v} for k, v in lab.items()} r.drills = [(fx, fy, d) for (fx, fy), d in r.drills] has = [bool(np.isin(r.ent[x0:x0 + 30, y0:y0 + 30], list(MACH)).any()) for r, _, x0, y0 in views] res = [] for r, lab, x0, y0 in views: w = cv.paste(r, x0, y0, 32, cv.edit(r, x0, y0, 32, random.Random(0))) tot, cr = cv.deliveries(w, cv._machine_items(w)[1]) res.append((tot > 0, cr > 0)) print(f"deliver {np.mean([a for a, _ in res]):.1%} machines {np.mean([b for (_, b), h in zip(res, has) if h]):.1%}")