New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getLastEventTime() has different behavior for client/module bots #860
Comments
Ah yes, the obvious solution to this is to |
@N00byEdge are you talking about changing the logic in the TM, or changing the logic in bwapi? If it's the former, I agree. If it's the latter, I don't really understand how bwapi would be able to determine whether In bwapi, I suggest mentioning in the documentation for Perhaps also consider giving |
@chriscoxe What you're suggesting sounds like a no-compromise solution, but it would leave TMs to have work to do for porting to 4.5+ and it would break source compatibility for any existing TMs, you would need to have one version of the source for 4.5 and one for 4.4 (since there is no |
@N00byEdge I'm still trying to understand what you're proposing, and whether you're talking about changing the TM, or bwapi, or both. You only mentioned the case where it's a client bot (and as I said, I don't understand what you're proposing for this case). What about the case where it's not a client bot - are you proposing different logic in this case? |
Maybe there was a typo in your proposal? Maybe you meant changing bwapi to " Personally, for non-client bots, I'd rather that bwapi times all events (not just |
I agree with your points but no, that was not a mistake, and I think you should reread it. Remember that "not running a client bot" means module. What I'm suggesting is that if the TM asks for the event time on a client bot, it should return 0 if it's not onFrame. That way we would only need to change this one functions implementation and not have to break existing TMs. |
(Edited) After looking at the src a few times I think I understand what you mean, and I agree it would solve the problem. (I got confused because I mistakenly thought |
On a related note, in BWAPI 4.4.0, it seems inconsistent that DLL bots (I'm talking about the bot specifically, not the TM) can use I think the documentation that says |
The doc is correct here. If your AI module (not TM) calls |
@heinermann Sorry, you are right that it returns 0. I was mistaken. |
I made a bot which just does the following:
This is a sample of the result:
Note the granular outputs of { 47, 62, 63 }. This highlights the low resolution of |
Here's an updated version, which compares the outputs of different timers:
This may indicate that the std::chrono timers are more precise, but might also mean that the duration of Sleep() correlates with the std::chrono times. But in general this result causes me to have more confidence in std::chrono. |
Yeah |
There are two issues with the current implementation of getLastEventTime():
getLastEventTime() works differently for client bots and module bots
Module bots use the following procedure, as implemented in
GameEvents.cpp
as called fromServer.cpp
:dwLastEventTime = GetTickCount()
SendClientEvent(client, e)
-- don't be thrown off by the namethis->lastEventTime = GetTickCount() - dwLastEventTime
SendClientEvent(tournamentAI, e)
Clients use a different procedure in
Server::update()
:BroodwarImpl.setLastEventTime(GetTickCount() - onFrameStart)
This means that when the tournament module calls
getLastEventTime()
:Let's say there's a bot that spends 1ms on each onUnitShow and 20ms on each onFrame. On a frame where two units show, and the bot takes 22ms to handle all its events. If the tournament manager adds up
getLastEventTime()
s for each event:Note that it's not possible for BWAPI to time client events individually, as clients can do whatever they want with the events provided, so no matter how this discrepancy is resolved, per-event measurements aren't a possibility.
getLastEventTime() uses a low-resolution timer that may misjudge the bot's performance
BWAPI's timing uses
GetTickCount()
which is a Windows API function:16 milliseconds is a lot, especially considering that any timer the bot might be using to regulate their performance may have error in the opposite direction; 16ms is 29% of the time allowed on frames in COG or AIIDE, for instance.
The text was updated successfully, but these errors were encountered: