void Constructor::handleNoBuildspotFound(UnitType toBuild) { bool removeOrder = false; if (toBuild.getID() == UnitTypes::Protoss_Photon_Cannon) removeOrder = true; if (toBuild.getID() == UnitTypes::Terran_Missile_Turret) removeOrder = true; if (toBuild.isAddon()) removeOrder = true; if (toBuild.getID() == UnitTypes::Zerg_Spore_Colony) removeOrder = true; if (toBuild.getID() == UnitTypes::Zerg_Sunken_Colony) removeOrder = true; if (toBuild.isResourceDepot()) removeOrder = true; if (toBuild.isRefinery()) removeOrder = true; if (removeOrder) { remove(toBuild); } if (!removeOrder) { if (isProtoss() && !supplyBeingBuilt()) { //Insert a pylon to increase PSI coverage if (!nextIsOfType(UnitTypes::Protoss_Pylon)) { buildPlan.insert(buildPlan.begin(), UnitTypes::Protoss_Pylon); } } } }
bool Constructor::shallBuildSupply() { UnitType supply = Broodwar->self()->getRace().getSupplyProvider(); //Check if we need supplies int supplyTotal = Broodwar->self()->supplyTotal() / 2; int supplyUsed = Broodwar->self()->supplyUsed() / 2; int preDiff = 2; //Speed up supply production in middle/late game if (supplyUsed > 30) preDiff = 4; if (supplyUsed <= supplyTotal - preDiff) { return false; } //Don't use automatic supply adding in the early game //to make it a bit more controlled. if (supplyUsed <= 30) { return false; } //Check if we have reached max supply if (supplyTotal >= 200) { return false; } //Check if there aready is a supply in the list if (nextIsOfType(supply)) { return false; } //Check if we are already building a supply if (supplyBeingBuilt()) { return false; } return true; }
bool BuildPlanner::shallBuildSupply() { UnitType supply = Broodwar->self()->getRace().getSupplyProvider(); //1. If command center is next in queue, dont build pylon /*if (buildOrder.size() > 0) { if (buildOrder.at(0).isResourceDepot()) { return false; } }*/ //2. Check if any building is unpowered (Protoss only) if (isProtoss()) { if (buildOrder.size() > 0) { if (buildOrder.at(0).type.getID() != UnitTypes::Protoss_Pylon.getID()) { vector<BaseAgent*> agents = AgentManager::getInstance()->getAgents(); for (int i = 0; i < (int)agents.size(); i++) { BaseAgent* agent = agents.at(i); if (agent->isAlive()) { Unit* cUnit = agent->getUnit(); if (cUnit->isUnpowered()) { return true; } } } } } } //3. Check if we need supplies int supplyTotal = Broodwar->self()->supplyTotal() / 2; int supplyUsed = Broodwar->self()->supplyUsed() / 2; if (supplyTotal - supplyUsed > 8) { return false; } if (supplyTotal >= 200) { //Reached max supply return false; } //4. Check if there is a supply already in the list if (nextIsOfType(supply)) { return false; } //5. Check if we are already building a supply if (supplyBeingBuilt()) { return false; } //Broodwar->printf("Supplies: %d/%d. Adding supply to buildorder", supplyUsed, supplyTotal); return true; }