| 16 | } |
| 17 | |
| 18 | void APMCounter::update(int frame) |
| 19 | { |
| 20 | // Note: formula from APMAlert |
| 21 | const long double APMInterval = 0.95L; // time after which actions are worth |
| 22 | |
| 23 | // Get the time difference between frames on fastest game speed (milliseconds). |
| 24 | // That's numFrames * 42ms / frame . |
| 25 | int timeDifference = (frame - lastUpdateFrame) * 42; |
| 26 | |
| 27 | int totalTime = frame * 42; |
| 28 | |
| 29 | // decay |
| 30 | botAPMCounter_selects = botAPMCounter_selects * std::exp(-timeDifference / (APMInterval * 60000)); |
| 31 | botAPMCounter_noselects = botAPMCounter_noselects * std::exp(-timeDifference / (APMInterval * 60000)); |
| 32 | |
| 33 | long double gameDurationFactor = 1.0L - std::exp(-totalTime / (APMInterval * 60000)); |
| 34 | if (gameDurationFactor < 1e-100L) gameDurationFactor = 1e-100L; //Prevent division by 0 |
| 35 | |
| 36 | botAPM_selects = static_cast<int>(botAPMCounter_selects / (APMInterval*gameDurationFactor)); |
| 37 | botAPM_noselects = static_cast<int>(botAPMCounter_noselects / (APMInterval*gameDurationFactor)); |
| 38 | |
| 39 | lastUpdateFrame = frame; |
| 40 | } |
| 41 | |
| 42 | void APMCounter::addSelect() |
| 43 | { |
no outgoing calls