Skip to content

Commit

Permalink
Update to Release 1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed Sep 7, 2018
1 parent 7a5306f commit 765d9c3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Steamhammer/Source/BuildingManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ void BuildingManager::removeBuildings(const std::vector< std::reference_wrapper<
{
for (Building & b : toRemove)
{
auto & it = std::find(_buildings.begin(), _buildings.end(), b);
auto it = std::find(_buildings.begin(), _buildings.end(), b);

if (it != _buildings.end())
{
Expand Down
30 changes: 15 additions & 15 deletions Steamhammer/Source/CombatCommander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ void CombatCommander::updateReconSquad()
if (unit->getType().isDetector())
{
reconSquad.removeUnit(unit);
break;
}
}
hasDetector = false;
Expand Down Expand Up @@ -460,6 +461,7 @@ void CombatCommander::updateAttackSquads()
if (unit->getType().isDetector())
{
groundSquad.removeUnit(unit);
break;
}
}
groundDetector = false;
Expand All @@ -471,6 +473,7 @@ void CombatCommander::updateAttackSquads()
if (unit->getType().isDetector())
{
flyingSquad.removeUnit(unit);
break;
}
}
flyingDetector = false;
Expand Down Expand Up @@ -525,7 +528,6 @@ void CombatCommander::updateAttackSquads()
if (flyingSquad.containsUnit(unit))
{
flyingSquad.removeUnit(unit);
UAB_ASSERT(_squadData.canAssignUnitToSquad(unit, groundSquad), "can't go to ground");
}
if (_squadData.canAssignUnitToSquad(unit, groundSquad))
{
Expand Down Expand Up @@ -713,11 +715,11 @@ void CombatCommander::updateScoutDefenseSquad()

if (assignScoutDefender)
{
// The enemy worker to catch.
BWAPI::Unit enemyWorker = *enemyUnitsInRegion.begin();

if (scoutDefenseSquad.isEmpty())
{
// The enemy worker to catch.
BWAPI::Unit enemyWorker = *enemyUnitsInRegion.begin();

BWAPI::Unit workerDefender = findClosestWorkerToTarget(_combatUnits, enemyWorker);

if (workerDefender)
Expand All @@ -743,7 +745,7 @@ void CombatCommander::updateBaseDefenseSquads()
{
return;
}

BWTA::BaseLocation * enemyBaseLocation = InformationManager::Instance().getEnemyMainBaseLocation();
BWTA::Region * enemyRegion = nullptr;
if (enemyBaseLocation)
Expand All @@ -766,15 +768,11 @@ void CombatCommander::updateBaseDefenseSquads()
continue;
}

// start off assuming all enemy units in region are just workers
const int numDefendersPerEnemyUnit = 2;

// all of the enemy units in this region
BWAPI::Unitset enemyUnitsInRegion;
for (const auto unit : BWAPI::Broodwar->enemy()->getUnits())
{
// If it's a harmless air unit, don't worry about it for base defense.
// TODO something more sensible
if (unit->getType() == BWAPI::UnitTypes::Zerg_Overlord ||
unit->getType() == BWAPI::UnitTypes::Protoss_Observer ||
unit->isLifted()) // floating terran building
Expand All @@ -789,8 +787,8 @@ void CombatCommander::updateBaseDefenseSquads()
}

// we ignore the first enemy worker in our region since we assume it is a scout
// This is because we can't catch it early. Should skip this check when we can.
// TODO replace with something sensible
// This is because we can't catch it early. Should skip this check when we can.
// TODO drop this when we are able to catch it
for (const auto unit : enemyUnitsInRegion)
{
if (unit->getType().isWorker())
Expand All @@ -813,7 +811,7 @@ void CombatCommander::updateBaseDefenseSquads()
_squadData.getSquad(squadName.str()).clear();
}

// and return, nothing to defend here
// Finished with this region, nothing to defend here.
continue;
}
else
Expand All @@ -834,7 +832,9 @@ void CombatCommander::updateBaseDefenseSquads()
UAB_ASSERT(_squadData.squadExists(squadName.str()), "Squad should exist: %s", squadName.str().c_str());
Squad & defenseSquad = _squadData.getSquad(squadName.str());

// figure out how many units we need on defense
// A simpleminded way of figuring out how much defense we need.
const int numDefendersPerEnemyUnit = 2;

int flyingDefendersNeeded = numDefendersPerEnemyUnit * numEnemyFlyingInRegion;
int groundDefendersNeeded = numDefendersPerEnemyUnit * numEnemyGroundInRegion;

Expand Down Expand Up @@ -878,7 +878,7 @@ void CombatCommander::updateBaseDefenseSquads()
}

// for each of our defense squads, if there aren't any enemy units near the position, clear the squad
// TODO partially overlaps with "is enemy in region check" above
// TODO partially overlaps with "is enemy in region check" above, could cause oscillating behavior
for (const auto & kv : _squadData.getSquads())
{
const Squad & squad = kv.second;
Expand Down Expand Up @@ -925,6 +925,7 @@ void CombatCommander::updateDefenseSquadUnits(Squad & defenseSquad, const size_t
if (unit->getType().isDetector())
{
defenseSquad.removeUnit(unit);
break;
}
}
hasDetector = false;
Expand Down Expand Up @@ -954,7 +955,6 @@ void CombatCommander::updateDefenseSquadUnits(Squad & defenseSquad, const size_t
while (flyingDefendersNeeded > flyingDefendersInSquad + flyingDefendersAdded &&
(defenderToAdd = findClosestDefender(defenseSquad, defenseSquad.getSquadOrder().getPosition(), true, false, enemyHasAntiAir)))
{
UAB_ASSERT(!defenderToAdd->getType().isWorker(), "flying worker defender");
_squadData.assignUnitToSquad(defenderToAdd, defenseSquad);
++flyingDefendersAdded;
}
Expand Down
2 changes: 1 addition & 1 deletion Steamhammer/Source/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Config
{
bool ConfigFileFound = false;
bool ConfigFileParsed = false;
std::string ConfigFileLocation = "bwapi-data/AI/Steamhammer_1.4.6.json";
std::string ConfigFileLocation = "bwapi-data/AI/Steamhammer_1.4.7.json";
}

namespace IO
Expand Down
6 changes: 3 additions & 3 deletions Steamhammer/Source/MicroOverlords.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class MicroOverlords : public MicroManager

public:
MicroOverlords();
void executeMicro(const BWAPI::Unitset & targets) {};

void update();
void executeMicro(const BWAPI::Unitset & targets) {};

void update();
};
};
18 changes: 9 additions & 9 deletions Steamhammer/Source/ScoutManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void ScoutManager::update()
}
if (moveScout)
{
moveGroundScout(_workerScout);
moveGroundScout();
}
}
else if (_gasStealOver)
Expand All @@ -226,7 +226,7 @@ void ScoutManager::update()

if (_overlordScout)
{
moveAirScout(_overlordScout);
moveAirScout();
}

drawScoutInformation(200, 320);
Expand Down Expand Up @@ -322,7 +322,7 @@ void ScoutManager::drawScoutInformation(int x, int y)
}

// Move the worker scout.
void ScoutManager::moveGroundScout(BWAPI::Unit scout)
void ScoutManager::moveGroundScout()
{
const int scoutDistanceThreshold = 30; // in tiles

Expand All @@ -338,19 +338,19 @@ void ScoutManager::moveGroundScout(BWAPI::Unit scout)

UAB_ASSERT(enemyBaseLocation, "no enemy base");

int scoutDistanceToEnemy = MapTools::Instance().getGroundTileDistance(scout->getPosition(), enemyBaseLocation->getPosition());
int scoutDistanceToEnemy = MapTools::Instance().getGroundTileDistance(_workerScout->getPosition(), enemyBaseLocation->getPosition());
bool scoutInRangeOfenemy = scoutDistanceToEnemy <= scoutDistanceThreshold;

// we only care if the scout is under attack within the enemy region
// this ignores if their scout worker attacks it on the way to their base
int scoutHP = scout->getHitPoints() + scout->getShields();
int scoutHP = _workerScout->getHitPoints() + _workerScout->getShields();
if (scoutHP < _previousScoutHP)
{
_scoutUnderAttack = true;
}
_previousScoutHP = scoutHP;

if (!scout->isUnderAttack() && !enemyWorkerInRadius())
if (!_workerScout->isUnderAttack() && !enemyWorkerInRadius())
{
_scoutUnderAttack = false;
}
Expand All @@ -371,7 +371,7 @@ void ScoutManager::moveGroundScout(BWAPI::Unit scout)
{
_scoutStatus = "Harass enemy worker";
_currentRegionVertexIndex = -1;
Micro::CatchAndAttackUnit(scout, closestWorker);
Micro::CatchAndAttackUnit(_workerScout, closestWorker);
}
// otherwise keep circling the enemy region
else
Expand All @@ -396,7 +396,7 @@ void ScoutManager::moveGroundScout(BWAPI::Unit scout)
}

// Move the overlord scout.
void ScoutManager::moveAirScout(BWAPI::Unit scout)
void ScoutManager::moveAirScout()
{
// get the enemy base location, if we have one
// Note: In case of an enemy proxy or weird map, this might be our own base. Roll with it.
Expand Down Expand Up @@ -804,7 +804,7 @@ void ScoutManager::calculateEnemyRegionVertices()

std::vector<BWAPI::Position> temp;

for (size_t s(maxFarthestEnd); s != maxFarthestStart; s = (s+1) % sortedVertices.size())
for (int s(maxFarthestEnd); s != maxFarthestStart; s = (s+1) % sortedVertices.size())
{
temp.push_back(sortedVertices[s]);
}
Expand Down
4 changes: 2 additions & 2 deletions Steamhammer/Source/ScoutManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class ScoutManager
BWAPI::Unit getTheEnemyGeyser() const;
BWAPI::Unit enemyWorkerToHarass() const;
void followPerimeter();
void moveGroundScout(BWAPI::Unit scout);
void moveAirScout(BWAPI::Unit scout);
void moveGroundScout();
void moveAirScout();
void drawScoutInformation(int x, int y);
void calculateEnemyRegionVertices();

Expand Down

0 comments on commit 765d9c3

Please sign in to comment.