diff --git a/Source/Analysis.cpp b/Source/Analysis.cpp index fd46859..98c2460 100644 --- a/Source/Analysis.cpp +++ b/Source/Analysis.cpp @@ -293,6 +293,7 @@ double Analysis::analyzeZergling() else { score += Util::countUnits(Macro::enemyIDs.front(), UnitTypes::Protoss_Dragoon) * 0.05; + score += Util::countUnits(Macro::enemyIDs.front(), UnitTypes::Terran_Machine_Shop) * 0.2; score += Util::countUnits(Macro::enemyIDs.front(), UnitTypes::Terran_Siege_Tank_Siege_Mode) * 0.1; score += Util::countUnits(Macro::enemyIDs.front(), UnitTypes::Terran_Siege_Tank_Tank_Mode) * 0.1; } diff --git a/Source/CBase.cpp b/Source/CBase.cpp index 256c2de..790582a 100644 --- a/Source/CBase.cpp +++ b/Source/CBase.cpp @@ -264,7 +264,7 @@ void CBase::setDefenseLocation() const BWEM::Area* targetArea = target.first; bool foundTarget = target.second; - if (foundTarget) + if (foundTarget && area != targetArea) { std::pair neighbor = Util::getNeighborArea(area, targetArea); const BWEM::Area* neighborArea = neighbor.first; @@ -283,10 +283,9 @@ void CBase::setDefenseLocation() else { Broodwar << "Couldn't find neighbor area in CBase::setDefenseLocation()" << std::endl; - Broodwar << targetArea->TopLeft() << std::endl; } } - else + else if(!foundTarget) { //Broodwar << area->TopLeft() << std::endl; Broodwar << "Couldn't find target area in CBase::setDefenseLocation()" << std::endl; diff --git a/Source/Macro.cpp b/Source/Macro.cpp index 1a28938..dc90d24 100644 --- a/Source/Macro.cpp +++ b/Source/Macro.cpp @@ -312,15 +312,7 @@ void Macro::onUnitDestroy(Unit unit) newBase = false; stopProduction = false; } - int queueIndex = -1; - for (size_t i = 0; i < queue.size(); i++) - { - if (queue.at(i).unit == players.at(id).units.at(index).targetUnit) - { - queueIndex = i; - break; - } - } + int queueIndex = Util::getQueueIndex(players.at(id).units.at(index).targetUnit); if (queueIndex > -1) queue.erase(queue.begin() + queueIndex); } @@ -360,15 +352,8 @@ void Macro::onUnitDestroy(Unit unit) { squads.at(squadindex).units.erase(squads.at(squadindex).units.begin() + unitindex); } - int scoutindex = -1; - for (size_t j = 0; j < scouts.size(); j++) - { - if (scouts.at(j).unit->getID() == unit->getID()) - { - scoutindex = j; - break; - } - } + + int scoutindex = Util::getScoutIndex(unit->getID()); if (scoutindex > -1) scouts.erase(scouts.begin() + scoutindex); } diff --git a/Source/Military.cpp b/Source/Military.cpp index 26ce680..1a477d6 100644 --- a/Source/Military.cpp +++ b/Source/Military.cpp @@ -90,7 +90,7 @@ void Military::checkDefense() { Macro::players.at(Macro::selfID).bases.at(i).getDefense(); double attackerScore = checkEnemiesAt(Macro::players.at(Macro::selfID).bases.at(i)); - if (attackerScore > 5) + if (attackerScore >= 5) { attacking = true; Macro::setLastAttack(Broodwar->getFrameCount()); @@ -135,7 +135,7 @@ void Military::checkDefense() double Military::checkEnemiesAt(CBase b) { double score = 0; - for (auto u : b.base->getUnitsInRadius(32*20, Filter::IsEnemy)) + for (auto u : b.base->getUnitsInRadius(32*15, Filter::IsEnemy)) { if (u->getType().groundWeapon() != WeaponTypes::None) { @@ -422,6 +422,7 @@ void Military::sendDefense(TilePosition tp, int attackerScore, int defenseScore) { if (defenseScore + Macro::squads.at(squadIndex).groundDamage < attackerScore + padding) { + // this is pulling drones when it shouldn't be if ((Util::isAttackingUnit(u) || droneDefenseNeeded()) && !u.isInSquad()) { Macro::squads.at(squadIndex).addUnit(u); diff --git a/Source/Util.cpp b/Source/Util.cpp index 664d0f0..e546eb3 100644 --- a/Source/Util.cpp +++ b/Source/Util.cpp @@ -218,6 +218,18 @@ int Util::getQueueIndex(UnitType ut) return -1; } +int Util::getScoutIndex(int unitID) +{ + for (size_t j = 0; j < Macro::scouts.size(); j++) + { + if (Macro::scouts.at(j).unit->getID() == unitID) + { + return j; + } + } + return -1; +} + int Util::getStaticDCount(int playerID, std::string type = "all") { if (type == "air") diff --git a/Source/Util.h b/Source/Util.h index c53dcd4..b418820 100644 --- a/Source/Util.h +++ b/Source/Util.h @@ -27,6 +27,7 @@ public: static std::pair getNeighborArea(const BWEM::Area* a1, const BWEM::Area* a2); static CBase getNextExpand(int playerID); static int getQueueIndex(UnitType ut); + static int getScoutIndex(int unitID); static int getStaticDCount(int playerID, std::string type); static std::pair getTargetArea(const BWEM::Area* startingArea, bool startLocation); static int getUnitIndex(Unit unit);