"""Offline shortest paths for installed Subseven wall-walking puzzle. Reads installed assets and last saved navigation only; outputs a reviewable plan. No input, imports of input helpers, or game/save modifications. """ import json,subprocess,sys,heapq,re from pathlib import Path R=Path(__file__).resolve().parents[1] sx,sy,tx,ty=map(int,sys.argv[1:5]) v=json.loads(subprocess.check_output(['ruby',str(R/'scripts/route_map.rb'),'871',str(sx),str(sy)],stderr=subprocess.DEVNULL)) w,h=v['width'],v['height'];data=v['data']['data'];pas=v['passages']['data'];pri=v['priorities']['data'];events=v['events'] blocked={(e['x'],e['y']) for e in events.values() if not e['through'] and e['character']} transfers={(e['x'],e['y']) for e in events.values() if any(c['code']==201 for c in e['list'] or []) and e['trigger'] in [1,2]} tiles={(e['x'],e['y']):e['tile_id'] for e in events.values() if not e['through'] and e['tile_id']>=0} def ok(x,y,d): if not(0<=x=0: na=(ax,ay) if abs(nx-ax)+abs(ny-ay)<=8 else (-1,-1) opts.append(((nx,ny,*na),['phase',k,nx,ny,ax,ay],1)) elif (nx,ny)not in blocked and ok(x,y,d)and ok(nx,ny,10-d):opts.append(((nx,ny,-1,-1),['walk',k,nx,ny],1)) for eid,(ex,ey)in statues.items(): if abs(ex-x)+abs(ey-y)==1 and (ax,ay)!=(ex,ey):opts.append(((x,y,ex,ey),['statue',int(eid),x,y],5)) for eid,(e,dest) in doorways.items(): if ax>=0 or abs(e['x']-x)+abs(e['y']-y)!=1:continue facing=6 if e['x']>x else 4 if e['x']y else 8 required={c['parameters'][2] for c in e['list'] if c['code']==111 and c['parameters'][:2]==[6,-1]} if required and facing not in required:continue opts.append(((*dest,-1,-1),['transfer',int(eid),*dest],4)) for nxt,action,weight in opts: nc=cost+weight+(500 if nxt[:2] in hazards else 0) if nc