google-code-export / bwapi

Automatically exported from code.google.com/p/bwapi
0 stars 0 forks source link

Feature request: Calculate effective order latency #158

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be helpful if BWAPI::Game offered a way to answer the question:

"If I issue an order now, on what frame will it be executed?"

See attached #BWAPI chat log for a discussion of the issue.

Original issue reported on code.google.com by Dan.G...@gmail.com on 3 Dec 2009 at 8:36

Attachments:

GoogleCodeExporter commented 9 years ago
so just a simple getLatency()?

Original comment by goo...@teabix.com on 3 Dec 2009 at 11:25

GoogleCodeExporter commented 9 years ago
probably

Original comment by AHeinerm on 3 Dec 2009 at 11:38

GoogleCodeExporter commented 9 years ago
Well, it sounds like it's not quite that. If The-Winner is accurate, then on 
LAN low
latency:

Order given on frame 1 > Executes on frame 5
Order given on frame 2 > Executes on frame 5
Order given on frame 3 > Executes on frame 7
Order given on frame 4 > Executes on frame 7

And that calculation gets trickier when latencies start changing. I don't know 
what
the precise behavior is, and it doesn't seem to be well-documented.

In short, it's an implementation detail which impacts gameplay and would be 
helpful
to know.

Original comment by Dan.G...@gmail.com on 4 Dec 2009 at 1:39

GoogleCodeExporter commented 9 years ago

Original comment by lowerlo...@gmail.com on 7 Dec 2009 at 1:12

GoogleCodeExporter commented 9 years ago

Original comment by lowerlo...@gmail.com on 7 Dec 2009 at 6:14

GoogleCodeExporter commented 9 years ago
from the chat:

-"my concern is knowing it in advance so I can save CPU by not 
recalculating/issuing 
orders until the last frame in the latency window"

If BWAPI will have a function to return the latency window, i doublt it will be 
BW-
memory readen, so eventually there will be bugs if someone is relying on this.

Are you sure it's not more stable to add a isCommandStarted() function and just 
call 
that one every frame?

Original comment by goo...@teabix.com on 7 Dec 2009 at 10:31

GoogleCodeExporter commented 9 years ago
"Are you sure it's not more stable to add a isCommandStarted() function and 
just call 
that one every frame?"

If the developer's goal is to spare resources by only calculating/issuing 
orders, a
hypothetical isCommandStarted() would not be sufficient to identify one can skip
issuing orders this frame.

But isCommandStarted() -- if I understand your intention correctly -- doesn't 
tell
you whether you can skip issuing orders until after the frame has already 
passed.

Original comment by Dan.G...@gmail.com on 8 Dec 2009 at 3:48

GoogleCodeExporter commented 9 years ago
Usually you can't just skip any orders even if you have the latency given.
For example, 7 frames of latency doesn't mean that you can only issue orders 
every
7th frame, but every order is delayed by 7 frames. If you issue an order at 
frame 3
and one at frame 5, one will be executed at frame 10 and one at frame 12. So 
you do
have to check at (almost) every frame what you want to do next.
A reliable latency value is still important because you have to know how far in
advance you have to give orders.

From what I hear and have seen myself, though, SC groups commands of 2 frames
together in some way, unless you play in singleplayer mode. I am not sure about 
the
details, but you can more or less skip orders every second frame. This seems 
not to
be affected by latency.

Original comment by Heckl.Jo...@googlemail.com on 8 Dec 2009 at 7:28

GoogleCodeExporter commented 9 years ago
If the grouping rule is just that -- blocks of two frames get transmitted 
together --
then indeed, this feature is unnecessary.

Original comment by Dan.G...@gmail.com on 8 Dec 2009 at 12:32

GoogleCodeExporter commented 9 years ago
Well, on battle.net there is maybe 15 frames latency.
And let's say we have something like that:
for each barracks in MyBarracks)
if (!barracks.isTraining()) train 1 marine.
And this updates every frame.
In single player it will train 1 marine at a time. Because on the next frame 
the if
condition will be false.
But if it's on battle.net, when the order "train marine" is issued, there is 15
frames delay, until the marine appears in the queue. So in this case the 
building
queue will be filled. The train order will be executed in the next 15 frames 
(on the
16th frame 1 marine appears in the queue). The solution is to execute this train
order every 15th frame. But for that we must know the value of the latency (low,
high, extra high). I think that it's possible with something like that
int i=0;
if (CC.getTrainingQueue.size()==0 train 1 SCV;
on every frame
{
if (CC.getTraninigQueue.size()==0) i++;
else latency=i;
}

When an order is issued, is there a way to check on the next frame, that an 
order was
issued?

Original comment by Nuclear...@gmail.com on 15 Feb 2010 at 11:30

GoogleCodeExporter commented 9 years ago
Currently doing this

Original comment by AHeinerm on 18 Aug 2010 at 4:52

GoogleCodeExporter commented 9 years ago
See r2680
Please verify

Original comment by AHeinerm on 18 Aug 2010 at 6:47