| 2341 | } |
| 2342 | |
| 2343 | double cTaskLib::Task_MatchNumber(cTaskContext& ctx) const |
| 2344 | { |
| 2345 | double quality = 0.0; |
| 2346 | const cArgContainer& args = ctx.GetTaskEntry()->GetArguments(); |
| 2347 | |
| 2348 | long long diff = ::llabs((long long)args.GetInt(0) - ctx.GetOutputBuffer()[0]); |
| 2349 | int threshold = args.GetInt(1); |
| 2350 | |
| 2351 | if (threshold < 0 || diff <= threshold) { // Negative threshold == infinite |
| 2352 | // If within threshold range, quality decays based on absolute difference |
| 2353 | double halflife = -1.0 * fabs(args.GetDouble(0)); |
| 2354 | quality = pow(2.0, static_cast<double>(diff) / halflife); |
| 2355 | } |
| 2356 | |
| 2357 | return quality; |
| 2358 | } |
| 2359 | |
| 2360 | |
| 2361 | void cTaskLib::Load_SortInputs(const cString& name, const cString& argstr, cEnvReqs& envreqs, Feedback& feedback) |
nothing calls this directly
no test coverage detected