Skip to content

Commit

Permalink
Merge pull request #2 from kant2002/version_14
Browse files Browse the repository at this point in the history
Update to version 1.4
  • Loading branch information
kant2002 authored Feb 24, 2018
2 parents 1bb2913 + 586a91b commit 18f78d6
Show file tree
Hide file tree
Showing 83 changed files with 4,447 additions and 1,506 deletions.
Binary file added BOSS/.DS_Store
Binary file not shown.
3 changes: 0 additions & 3 deletions BOSS/source/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,11 @@ class Timer
return this->getElapsedTimeInMicroSec() * 0.001;
}


double getElapsedTimeInSec()
{
return this->getElapsedTimeInMicroSec() * 0.000001;
}



double getElapsedTime()
{
return this->getElapsedTimeInSec();
Expand Down
Binary file added Steamhammer/.DS_Store
Binary file not shown.
7 changes: 3 additions & 4 deletions Steamhammer/Source/BOSSManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ BOSSManager::BOSSManager()
, _searchInProgress(false)
, _previousStatus("No Searches")
{

}

void BOSSManager::reset()
Expand Down Expand Up @@ -65,7 +64,7 @@ void BOSSManager::startNewSearch(const std::vector<MetaPair> & goalUnits)
_totalPreviousSearchTime = 0;
_previousGoalUnits = goalUnits;
}
catch (const BOSS::BOSSException)
catch (const BOSS::BOSSException &)
{
if (Config::Debug::DrawBuildOrderSearchInfo)
{
Expand Down Expand Up @@ -138,7 +137,7 @@ void BOSSManager::update(double timeLimit)
// this will resume a search in progress or start a new search if not yet started
_smartSearch->search();
}
catch (const BOSS::BOSSException)
catch (const BOSS::BOSSException &)
{
if (Config::Debug::DrawBuildOrderSearchInfo)
{
Expand Down Expand Up @@ -222,7 +221,7 @@ void BOSSManager::update(double timeLimit)
return;
}
// and if that search doesn't work then we're out of luck, no build orders for us
catch (const BOSS::BOSSException)
catch (const BOSS::BOSSException &)
{
//UAB_ASSERT_WARNING(false, "BOSS Timeout Naive Search Exception: %s", exception.what());
_previousStatus += "\x08Naive Exception";
Expand Down
2 changes: 2 additions & 0 deletions Steamhammer/Source/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void Base::findGeysers()
}
}

// The depot may be null. (That's why player is a separate argument, not depot->getPlayer().)
// A null depot for an owned base means that the base is inferred and hasn't been seen.
void Base::setOwner(BWAPI::Unit depot, BWAPI::Player player)
{
resourceDepot = depot;
Expand Down
38 changes: 37 additions & 1 deletion Steamhammer/Source/BuildOrderQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ void BuildOrderQueue::doneWithHighestPriorityItem()
queue.pop_back();
}

void BuildOrderQueue::pullToTop(size_t i)
{
UAB_ASSERT(i >= 0 && i < queue.size()-1, "bad index");

BuildOrderItem item = queue[i]; // copy it
queue.erase(queue.begin() + i);
queueAsHighestPriority(item.macroAct, item.isGasSteal); // this sets modified = true
}

size_t BuildOrderQueue::size() const
{
return queue.size();
Expand Down Expand Up @@ -113,6 +122,21 @@ bool BuildOrderQueue::anyInQueue(BWAPI::UnitType type) const
return false;
}

// Are there any of these in the next N items in the queue?
bool BuildOrderQueue::anyInNextN(BWAPI::UnitType type, int n) const
{
for (int i = queue.size() - 1; i >= std::max(0, int(queue.size()) - 1 - n); --i)
{
const MacroAct & act = queue[i].macroAct;
if (act.isUnit() && act.getUnitType() == type)
{
return true;
}
}

return false;
}

size_t BuildOrderQueue::numInQueue(BWAPI::UnitType type) const
{
size_t count = 0;
Expand All @@ -137,6 +161,18 @@ void BuildOrderQueue::totalCosts(int & minerals, int & gas) const
}
}

bool BuildOrderQueue::isGasStealInQueue() const
{
for (const auto & item : queue)
{
if (item.isGasSteal)
{
return true;
}
}
return false;
}

void BuildOrderQueue::drawQueueInformation(int x, int y, bool outOfBook)
{
if (!Config::Debug::DrawProductionInfo)
Expand Down Expand Up @@ -185,7 +221,7 @@ void BuildOrderQueue::drawQueueInformation(int x, int y, bool outOfBook)
prefix = white;
}

BWAPI::Broodwar->drawTextScreen(x, y, " %c%s", prefix, TrimRaceName(act.getName()).c_str());
BWAPI::Broodwar->drawTextScreen(x, y, " %c%s", prefix, NiceMacroActName(act.getName()).c_str());
y += 10;
}

Expand Down
9 changes: 6 additions & 3 deletions Steamhammer/Source/BuildOrderQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ struct BuildOrderItem

class BuildOrderQueue
{
std::deque< BuildOrderItem > queue;
bool modified; // so ProductionManager can detect changes made behind its back
std::deque< BuildOrderItem > queue; // highest priority item is in the back
bool modified; // so ProductionManager can detect changes made behind its back

void queueItem(BuildOrderItem b); // queues something with a given priority
void queueItem(BuildOrderItem b); // queues something with a given priority

public:

Expand All @@ -37,6 +37,7 @@ class BuildOrderQueue
void queueAsLowestPriority(MacroAct m); // queues something at the lowest priority
void removeHighestPriorityItem(); // removes the highest priority item
void doneWithHighestPriorityItem(); // removes highest priority item without setting `modified`
void pullToTop(size_t i); // move item at index i to the highest priority position

size_t size() const; // number of items in the queue
bool isEmpty() const;
Expand All @@ -47,8 +48,10 @@ class BuildOrderQueue

bool anyInQueue(BWAPI::UpgradeType type) const;
bool anyInQueue(BWAPI::UnitType type) const;
bool anyInNextN(BWAPI::UnitType type, int n) const;
size_t numInQueue(BWAPI::UnitType type) const;
void totalCosts(int & minerals, int & gas) const;
bool isGasStealInQueue() const;

void drawQueueInformation(int x, int y, bool outOfBook);

Expand Down
Loading

0 comments on commit 18f78d6

Please sign in to comment.