Download scripts/flow_debug/diagnose_machines.py from beyarkay/factorio-blueprints: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/diagnose_machines.py
- Command line
-
hf download hf://datasets/beyarkay/factorio-blueprints/scripts/flow_debug/diagnose_machines.py
-
curl -L -o diagnose_machines.py https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/diagnose_machines.py
1.21 kB
| """For views with a machine, what blocks crafted output?""" | |
| import glob, sys, collections | |
| import numpy as np, torch | |
| from functional import MACH, C, sample, window, crafted_delivery, io_items, SRC, SNK, E | |
| from measure import CONFIGS | |
| from factorion import Channel, count_unpowered | |
| views = sample(sorted(glob.glob(sys.argv[1])), int(sys.argv[2])) | |
| cfg = CONFIGS[sys.argv[3]] | |
| c = collections.Counter() | |
| for r, lab, x0, y0 in views: | |
| if not np.isin(r.ent[x0:x0 + 30, y0:y0 + 30], list(MACH)).any(): | |
| continue | |
| c["views with a machine"] += 1 | |
| w, _ = window(r, lab, x0, y0, cfg) | |
| ent = w[C[0]] | |
| if crafted_delivery(w) > 0: | |
| c["works"] += 1; continue | |
| c["fails"] += 1 | |
| if not np.isin(ent, list(MACH)).any(): c[" machine cut off by the window edge"] += 1; continue | |
| if count_unpowered(torch.from_numpy(w)) > 0: c[" something still unpowered"] += 1 | |
| if not (ent == SRC).any(): c[" no source at all"] += 1 | |
| if not (ent == SNK).any(): c[" no sink at all"] += 1 | |
| ins, outs = io_items(w) | |
| src_items = set(w[C[2]][ent == SRC].tolist()) | |
| if ins and not (ins & src_items): c[" no source supplies any ingredient"] += 1 | |
| for k, v in c.items(): | |
| print(f"{k:45s} {v}") | |