14 probdist_pick(struct probdist
*restrict pd
, coord_t
*restrict ignore
)
16 double total
= probdist_total(pd
) - PROBDIST_EPSILON
;
18 double stab
= fast_frandom() * total
;
20 fprintf(stderr
, "stab %f / %f\n", stab
, total
);
24 while (stab
> pd
->rowtotals
[r
] + PROBDIST_EPSILON
) {
26 fprintf(stderr
, "[%s] skipping row %f (%f)\n", coord2sstr(c
, pd
->b
), pd
->rowtotals
[r
], stab
);
28 stab
-= pd
->rowtotals
[r
];
29 r
++; assert(r
< board_size(pd
->b
));
31 c
+= board_size(pd
->b
);
32 while (!is_pass(*ignore
) && *ignore
<= c
)
36 for (; c
< board_size2(pd
->b
); c
++) {
38 fprintf(stderr
, "[%s] %f (%f)\n", coord2sstr(c
, pd
->b
), pd
->items
[c
], stab
);
40 assert(is_pass(*ignore
) || c
<= *ignore
);
43 fprintf(stderr
, "ignored\n");
48 if (stab
<= pd
->items
[c
])
53 fprintf(stderr
, "overstab %f (total %f)\n", stab
, total
);