zloop1982 / bwapi

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

Repair shouldn't be a valid command if don't have enough resources #456

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. My bot is playing Terran (or Protoss and has mind-controlled an SCV and 
built a Terran command center etc...).  During an frame when my bot has 0 
minerals and 0 gas and my command center is damaged and my SCV is idle, check 
the return value of the following canIssueCommand() call (where "scv" is a 
pointer to the SCV Unit, and "commandCenter" is a pointer to the command center 
Unit):
UnitCommand unitCmd;
unitCmd.unit = scv;
unitCmd.type = UnitCommandTypes::Repair;
unitCmd.target = commandCenter;
if (scv->canIssueCommand(unitCmd))
{
    Broodwar->printf("I can repair");
    scv->repair(commandCenter);
}
else
{
    Broodwar->printf("I can not repair");
}

What is the expected output? What do you see instead?
Expected output: "I can not repair" printed on screen.
Actual output: "I can repair" printed on screen and Broodwar immediately 
displays a message saying "Not enough minerals...mine more minerals." and 
Broodwar's audio says "Not enough minerals".

What version of the product are you using? On what operating system?
BWAPI 3.7.4 on WinXP SP3 32-bit.

Please provide any additional information below.
Note that canIssueCommand() returns false for a UnitCommandTypes::Train command 
if the bot has insufficient resources.
Also note that it would need to check for sufficient minerals and gas.  I 
suppose the amount of each required depends on how much the target unit costed. 
 AFAIK, repairing is done in cycles until the target unit is fully repaired or 
we run out of minerals and/or gas.  Maybe it's not easy to calculate how much 
minerals & gas are required for one repair cycle.

Original issue reported on code.google.com by chris.c...@gmail.com on 24 Aug 2012 at 7:45

GoogleCodeExporter commented 9 years ago
This isn't a bug, it's actually how starcraft works internally.  You can see it 
with the following example: Trying to go to a place on the map which is 
inaccessible from a unit's location.  The unit will try to get as close as 
possible and then complete.  So the command is a valid command but when it 
tries to execute it it may or may not fail.  Repairing something requires going 
to there and so it is possible to go there and try to repair even if you can't. 
 You can do this in Starcraft as well, it's not an issue with BWAPI.

Original comment by pawngam...@gmail.com on 1 Sep 2012 at 4:47

GoogleCodeExporter commented 9 years ago
Ok, that explains it.  I realize that if the SCV is far away, even if I have 0 
minerals, it does go to the command center and if I have gained some minerals 
by the time it reaches it, it starts repairing.  So I've marked this issue as 
Invalid (sorry - my bad).

Original comment by chris.c...@gmail.com on 2 Sep 2012 at 10:30