Download scripts/flow_debug/poles_check.py from beyarkay/factorio-blueprints: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/poles_check.py
- Command line
-
hf download hf://datasets/beyarkay/factorio-blueprints/scripts/flow_debug/poles_check.py
-
curl -L -o poles_check.py https://huggingface.co/datasets/beyarkay/factorio-blueprints/resolve/main/scripts/flow_debug/poles_check.py
1.18 kB
| import glob, random, sys | |
| import numpy as np | |
| import factorion_rs | |
| import corpus.convert as cv | |
| from factorion import count_unpowered | |
| from functional import sample | |
| views = sample(sorted(glob.glob(sys.argv[1])), 300, nudge=True) | |
| stats = {"unpowered before": 0, "placed": 0, "works with": 0, "works without": 0} | |
| orig = factorion_rs.py_place_poles | |
| for r, lab, x0, y0 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] | |
| calls = [] | |
| def spy(w): calls.append(count_unpowered(__import__("torch").from_numpy(np.ascontiguousarray(w.transpose(2, 0, 1))))); out = orig(w); calls.append(out is not None); return out | |
| factorion_rs.py_place_poles = spy | |
| w = cv.paste(r, x0, y0, 32, cv.edit(r, x0, y0, 32, random.Random(0))) | |
| factorion_rs.py_place_poles = lambda w: None | |
| w2 = cv.paste(r, x0, y0, 32, cv.edit(r, x0, y0, 32, random.Random(0))) | |
| stats["unpowered before"] += calls[0] > 0; stats["placed"] += calls[1] and calls[0] > 0 | |
| stats["works with"] += cv.deliveries(w, set())[0] > 0; stats["works without"] += cv.deliveries(w2, set())[0] > 0 | |
| print(stats) | |