MCPcopy Create free account
hub / github.com/bwapi/bwapi / update

Method update

bwapi/BWAPICore/APMCounter.cpp:18–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18void 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
42void APMCounter::addSelect()
43{

Callers 3

mainFunction · 0.45
TEST_METHODFunction · 0.45
mainFunction · 0.45

Calls

no outgoing calls

Tested by 1

TEST_METHODFunction · 0.36