Custom Bruteforce Evaluation
TMInterface exposes the RegisterBruteforceEvaluation
API which allows plugins to register a custom bruteforce evaluation function. This function is called when
the built-in bruteforce algorithm is active and the evaluation is selected in the Settings > Bruteforce > Optimization menu:
void RenderEvalSettings()
{
// Render the evaluation settings.
}
int bestTime = -1;
BFEvaluationResponse@ OnEvaluate(SimulationManager@ simManager, const BFEvaluationInfo&in info)
{
int raceTime = simManager.RaceTime;
auto resp = BFEvaluationResponse();
if (info.Phase == BFPhase::Initial) {
if (simManager.PlayerInfo.RaceFinished) {
print("Base run: " + Time::Format(raceTime));
bestTime = raceTime;
resp.Decision = BFEvaluationDecision::Accept;
}
} else if (simManager.PlayerInfo.RaceFinished) {
if (raceTime < bestTime) {
resp.Decision = BFEvaluationDecision::Accept;
print("New time: " + Time::Format(raceTime));
resp.ResultFileStartContent = "# Found better simple finish time: " + Time::Format(raceTime);
}
}
return resp;
}
void Main() {
RegisterBruteforceEvaluation("simplefinish", "Simple Finish Time", OnEvaluate, RenderEvalSettings);
}
For more information, check out BFEvaluationResponse
and BFEvaluationInfo
reference.