14 probdist_pick(struct probdist
*pd
, coord_t
*ignore
)
16 double total
= probdist_total(pd
) - PROBDIST_EPSILON
;
18 double stab
= fast_frandom() * total
;
20 fprintf(stderr
, "stab %f / %f\n", stab
, total
);
23 while (stab
> pd
->rowtotals
[r
] + PROBDIST_EPSILON
) {
24 stab
-= pd
->rowtotals
[r
];
26 assert(r
< board_size(pd
->b
));
28 for (coord_t c
= r
* board_size(pd
->b
); c
< board_size2(pd
->b
); c
++) {
30 fprintf(stderr
, "[%s] %f (%f)\n", coord2sstr(c
, pd
->b
), pd
->items
[c
], stab
);
35 if (stab
<= pd
->items
[c
])
40 fprintf(stderr
, "overstab %f (total %f)\n", stab
, total
);