sclass BestOfN implements Steppable {
IF1 scoreFunction;
IF0 produce;
long nMax = 1000;
double stopScore = infinity();
long attempt;
new Best best;
*(IF1 *scoreFunction, IF0 *produce, int *nMax) {}
*(IF1 *scoreFunction, int *nMax) {}
public bool step() {
if (attempt >= nMax || best.score() >= stopScore) false;
++attempt;
A a = produce!;
double score = scoreFunction.get(a);
best.put(a, score);
true;
}
run { stepAll(this); }
Scored get() {
run();
ret best.scored();
}
double score() {
ret best.score();
}
long attempts() { ret attempt; }
}