544
544
ifree = is_orth->count - island_countbridges(is_orth);
546
nsurrspc += min(ifree, MAXIMUM(is->state, dx,
547
is->adj.points[i].x, is->adj.points[i].y));
547
* ifree is the number of bridges unfilled in the other
548
* island, which is clearly an upper bound on the number
549
* of extra bridges this island may run to it.
551
* Another upper bound is the number of bridges unfilled
552
* on the specific line between here and there. We must
553
* take the minimum of both.
555
int bmax = MAXIMUM(is->state, dx,
556
is->adj.points[i].x, is->adj.points[i].y);
557
int bcurr = GRIDCOUNT(is->state,
558
is->adj.points[i].x, is->adj.points[i].y,
559
dx ? G_LINEH : G_LINEV);
560
assert(bcurr <= bmax);
561
nsurrspc += min(ifree, bmax - bcurr);
549
564
if (nsurrspc < nspc) {
550
565
debug(("island at (%d,%d) impossible: surr. islands %d spc, need %d.\n",
2730
2745
/* I don't think this wants a border. */
2748
loff = ts / (8 * sqrt((state->params.maxb - 1)));
2733
2749
print_line_width(dr, ts / 12);
2734
2750
for (x = 0; x < state->w; x++) {
2735
2751
for (y = 0; y < state->h; y++) {
2740
2756
if (grid & G_ISLAND) continue;
2741
2757
if (grid & G_LINEV) {
2743
draw_line(dr, cx+ts/2-loff, cy, cx+ts/2-loff, cy+ts, ink);
2744
draw_line(dr, cx+ts/2+loff, cy, cx+ts/2+loff, cy+ts, ink);
2746
draw_line(dr, cx+ts/2, cy, cx+ts/2, cy+ts, ink);
2758
for (i = 0; i < nl; i++)
2759
draw_line(dr, cx+ts/2+(2*i-nl+1)*loff, cy,
2760
cx+ts/2+(2*i-nl+1)*loff, cy+ts, ink);
2749
2762
if (grid & G_LINEH) {
2751
draw_line(dr, cx, cy+ts/2-loff, cx+ts, cy+ts/2-loff, ink);
2752
draw_line(dr, cx, cy+ts/2+loff, cx+ts, cy+ts/2+loff, ink);
2754
draw_line(dr, cx, cy+ts/2, cx+ts, cy+ts/2, ink);
2763
for (i = 0; i < nl; i++)
2764
draw_line(dr, cx, cy+ts/2+(2*i-nl+1)*loff,
2765
cx+ts, cy+ts/2+(2*i-nl+1)*loff, ink);