app
Codex
Public Made by Adomby adom
Codex in Adom Hydrogen: ecosystem setup, dock dashboard and live engineering demos.
main
John Lauer
Corrected Astra ESC routing: native zero-open result, full accounting and voiceover handoff
a80479d
23d ago
from component_search import *
history=np.zeros((3,H,W),dtype=np.uint16)
def search_soft(net,width,source,target,allow_planes=False):
old=list(m.copper)
m.copper[:]=[c for c in old if c['net']==net or (not allow_planes and c['net'] in ['GND','+3V3'])]
a=masks(net,width);m.copper[:]=old
pen=np.zeros((3,H,W),dtype=np.uint16)
for c in old:
if c['net']==net or (not allow_planes and c['net'] in ['GND','+3V3']):continue
for z in c['zs']:raster(pen[z],c['g'].buffer(.205+width/2),100 if c['net'] in ['GND','+3V3'] else 30)
raster(pen[2],c['g'].buffer(.205+.4),30)
pen=np.minimum(pen+history,60000);pen.tofile('penalty.bin')
start=np.zeros((2,H,W),dtype=np.uint8);goal=np.zeros_like(start)
for collection,arr in [(source,start),(target,goal)]:
for c in collection:
for z in c['zs']:raster(arr[z],c['g'].buffer(width/2-.005))
arr[a[:2]>0]=0
ids=np.flatnonzero(start)
if not len(ids) or not np.any(goal):return None
g=unary_union([c['g'] for c in target]);t=g.centroid;tx,ty=ij(t.x,t.y)
a.tofile('mask.bin');goal.tofile('goal.bin')
r=subprocess.run(['./search3'],input=f'{W} {H} 0 {tx} {ty} {len(ids)} '+' '.join(map(str,ids)),capture_output=True,text=True)
raw=json.loads(r.stdout)
if not raw:return None
out=[];curz=0
for i,j,z in compress(raw):
x,y=xy(i,j)
if z!=curz or (not out and z):out.append(dict(x=x,y=y,layer='B.Cu' if z else 'F.Cu'))
elif not out or [x,y]!=out[-1]:out.append([x,y])
curz=z
return out