Download scripts/flow_debug/diagnose_all.py from beyarkay/factorio-blueprints: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/diagnose_all.py
- Command line
-
hf download hf://datasets/beyarkay/factorio-blueprints/scripts/flow_debug/diagnose_all.py
-
curl -L -o diagnose_all.py https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/diagnose_all.py
1.26 kB
| import glob, sys, collections | |
| import numpy as np, torch | |
| from functional import MACH, C, SRC, SNK, BELTISH, SPLIT, INS, sample, window, thput, E | |
| from measure import CONFIGS | |
| views = sample(sorted(glob.glob(sys.argv[1])), int(sys.argv[2])) | |
| cfg = CONFIGS[sys.argv[3]] | |
| c, ex = collections.Counter(), collections.defaultdict(list) | |
| for i, (r, lab, x0, y0) in enumerate(views): | |
| w, why = window(r, lab, x0, y0, cfg) | |
| if thput(w) > 0: | |
| c["delivers"] += 1; continue | |
| ent = w[C[0]] | |
| n_src, n_snk = int((ent == SRC).sum()), int((ent == SNK).sum()) | |
| belts = int(np.isin(ent, list(BELTISH | {SPLIT})).sum()) | |
| interior_masked = int((r.inst[x0:x0 + 30, y0:y0 + 30] == -1).mean() * 100) | |
| if belts == 0 and not np.isin(ent, list(MACH | set(INS))).any(): | |
| k = "no known flow entities left in the interior" | |
| elif n_src == 0 and n_snk == 0: | |
| k = "no flow crosses the window edge" | |
| elif n_src == 0: | |
| k = "sinks but no source" | |
| elif n_snk == 0: | |
| k = "sources but no sink" | |
| else: | |
| k = "sources and sinks, but nothing connects them" | |
| c[k] += 1; ex[k].append(i) | |
| c[f" (interior >30% masked)"] += interior_masked > 30 | |
| for k, v in c.most_common(): | |
| print(f"{k:50s} {v:4d} e.g. {ex.get(k, [])[:6]}") | |