Hey Guys,
Firstly this is my first post here, and I am an ultra noob in coding.
My problem is I am unable to have idle/just spawned SCV's to gather minerals.
This is my code here:
for(std::set<Unit*>::const_iterator i= Broodwar->self()->getUnits().begin();i!=Broodwar->self()->getUnits().end();i++){
//Broodwar->sendText("collecting all units information");
if ((*i)->getType().isWorker())
{
if ((*i)->isGatheringMinerals()){
Broodwar->sendText("is gathering minerals");
}
else
{
Unit* closestMineral=NULL;
Broodwar->sendText("getting free workers1");
for(std::set<Unit*>::iterator m=mineralFieldsLeft.begin();m!=mineralFieldsLeft.end();m++)
{
if (closestMineral==NULL || (*i)->getDistance(*m)<(*i)->getDistance(closestMineral))
closestMineral=*m;
}
if (closestMineral!=NULL){
(*i)->rightClick(closestMineral);
mineralFieldsLeft.erase(closestMineral);
}
}
}
}
mineralFieldsList is already defined, but it seems that when it's playing starcraft, the message getting free workers does show up, but I don't know now what to do, because the free worker won't mine minerals.
Any help would be greatly appreciated.
Thanks,
darklord
Idle SCV to gather minerals
-
- Posts: 5
- Joined: Wed Jan 12, 2011 5:52 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
-
- Posts: 5
- Joined: Wed Jan 12, 2011 5:52 am [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Return to “AI development (BWAPI Bots)”
Who is online
Users browsing this forum: No registered users and 10 guests