14 probdist_pick(struct probdist
*restrict pd
, coord_t
*restrict ignore
)
16 fixp_t total
= probdist_total(pd
);
17 fixp_t stab
= fast_irandom(total
);
19 fprintf(stderr
, "stab %f / %f\n", fixp_to_double(stab
), fixp_to_double(total
));
22 coord_t c
= board_size(pd
->b
) + 1;
23 while (stab
> pd
->rowtotals
[r
]) {
25 fprintf(stderr
, "[%s] skipping row %f (%f)\n", coord2sstr(c
, pd
->b
), fixp_to_double(pd
->rowtotals
[r
]), fixp_to_double(stab
));
27 stab
-= pd
->rowtotals
[r
];
28 r
++; assert(r
< board_size(pd
->b
));
30 c
+= board_size(pd
->b
);
31 while (!is_pass(*ignore
) && *ignore
<= c
)
35 for (; c
< board_size2(pd
->b
); c
++) {
37 fprintf(stderr
, "[%s] %f (%f)\n", coord2sstr(c
, pd
->b
), fixp_to_double(pd
->items
[c
]), fixp_to_double(stab
));
39 assert(is_pass(*ignore
) || c
<= *ignore
);
42 fprintf(stderr
, "\tignored\n");
47 if (stab
<= pd
->items
[c
])
52 fprintf(stderr
, "overstab %f (total %f)\n", fixp_to_double(stab
), fixp_to_double(total
));