IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Is the effect of training/morphing always immediate?
daan   
Jul 24 2010, 10:13 AM    Post #1
Hey, I'm building a bot for the competition and am working on code that handles unit training.

My question is: will the result of the unit->train(type) command always be available the same frame it was issued, or could it be later under (high) latency?

Here's a code that might illustrate my problem:

CODE
int myMinerals = Broodwar->self()->minerals();
BWAPI::Unit* unit = getCommandCenter();
BWAPI::UnitType type = UnitTypes::Terran_SCV;
bool success = unit->train(type);
assert(success == unit->isTraining());
if(success) myMinerals -= unit->mineralPrice();
assert(myMinerals == Broodwar->self()->minerals());


It seems to work on my system, but my code has only played locally against the cpu.


 
Go to the top of the page +
daan   
Jul 24 2010, 01:04 PM    Post #2
My question has been answered by lowerlogic on Quakenet #bwapi, in my words:

Starcraft uses latency compensation. This means that when BWAPI responds true to a command like train() it will have checked internally to see if you have enough resources and tech to actually produce the unit. This means that it is very unlikely the command failed and/or commands like Broodwar->self()->minerals() will be inaccurate.


 
Go to the top of the page +
lowerlogic    Massachusetts, U.S.
Jul 24 2010, 07:06 PM    Post #3
I just tried the testing framework in a match with lan latency and the test cases all started failing, so it looks like right now the latency compensation only works correctly for single player games. Sorry sad.gif. Rather depressing considering I spent at least a week hammering away at those test cases to get the all latency compensation code to work correctly, only to find out it only works in single player games.


 
Go to the top of the page +
krasi0   
Jul 25 2010, 04:19 AM    Post #4
lowerlogic, cheer up! I don't think this is a dead end so we're gonna come up with another idea to compensate latency.


 
Go to the top of the page +

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 7th September 2010 - 06:03 PM