abstract sclass AIStrategy implements Steppable {
// user must set
F1 submit; // scoring function
*() {}
*(F1 *submit) {}
selfType setJudge(IF1 judge) {
submit = func(A a) -> double { judge.get(a).doubleValue() };
this;
}
long round;
new Best best;
bool verbose;
event newBest(A guess, double score);
void updateBest(A guess, double score) {
if (best.put(guess, score))
newBest(guess, score);
}
double submit(A guess) {
if (guess == null) ret best.worstScore();
double score = callF(submit, guess);
updateBest(guess, score);
ret score;
}
selfType lowerIsBetter(bool b) {
best.lowerIsBetter(b);
this;
}
}