@x @d infty max_nodes /* the ``score'' of a completely unconstrained item */ @y @d infty 0x7fffffff /* the ``score'' of a completely unconstrained item */ @z @x in search for best_itm, give pref to items whose name begins with # if (t<=score) { @y if (t<=score && t>1 && (o,cl[k].name[0]!='#')) t+=last_node; if (t<=score) { @z @x if ((vbose&show_details) && @y if (score>last_node && score='0' && x<='9') x=x-'0'; else if (x>='a' && x<='z') x=x-'a'+10; else if (x>='A' && x<='Z') x=x-'A'+36; else panic("Bad x coordinate"); if (y>='0' && y<='9') y=y-'0'; else if (y>='a' && y<='z') y=y-'a'+10; else if (y>='A' && y<='Z') y=y-'A'+36; else panic("Bad y coordinate"); if (x>xmax) xmax=x; if (y>ymax) ymax=y; d=nd[cc].color; if (!box[x+1][y+1] && d!='.') box[x+1][y+1]=d,l++,xy=(x<<8)+y; nextr:@+ if (r==choice[k]) break; r++; } } @; for (x=0;x<=xmax;x++) { if (x) printf("|"); for (y=0;y<=ymax;y++) printf(""O"c",box[x+1][y+1]? box[x+1][y+1]-0x80:'.'); } printf(" #"O"lld\n",count); fflush(stdout); cleanup:@+for (x=0;x<=xmax;x++) for (y=0;y<=ymax;y++) box[x+1][y+1]=0; } @z @x @*Index. @y @ Ye olde depth-first search. @d mark(xx,yy) {@+if (box[(xx)+1][(yy)+1] && box[(xx)+1][(yy)+1]<0x80) l--,stack[s++]=((xx)<<8)+(yy),box[(xx)+1][(yy)+1]+=0x80;@+} @= s=0; mark(xy>>8,xy&0xff); @; if (l) goto cleanup; @ @= while (s) { s--,x=stack[s]>>8,y=stack[s]&0xff; mark(x-1,y); mark(x+1,y); mark(x,y-1); mark(x,y+1); } @ @= unsigned char box[64][64]; /* allow space for margins in both coordinates */ int xmax,ymax; int stack[62*62]; @*Index. @z