Skip to content

Commit

Permalink
Update to SteamHammer 3.5.10
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed Dec 8, 2022
1 parent 375756e commit bb4f537
Show file tree
Hide file tree
Showing 168 changed files with 25,709 additions and 22,024 deletions.
6 changes: 3 additions & 3 deletions BOSS/VisualStudio/BOSS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@
<ProjectGuid>{9F8709E3-AC4F-45F2-8105-4A99D8E2A127}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>StarcraftBuildOrderSearch</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
2 changes: 1 addition & 1 deletion BOSS/source/DFBB_BuildOrderSmartSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void DFBB_BuildOrderSmartSearch::calculateSearchSettings()
_goal.setGoalMax(resourceDepot, _initialState.getUnitData().getNumTotal(resourceDepot));

// set the number of refineries
_goal.setGoalMax(refinery, std::min((UnitCountType)3, calculateRefineriesRequired()));
_goal.setGoalMax(refinery, std::min((UnitCountType)6, calculateRefineriesRequired()));

// set the maximum number of workers to an initial ridiculously high upper bound
_goal.setGoalMax(worker, std::min(_initialState.getUnitData().getNumTotal(worker) + 20, 100));
Expand Down
4 changes: 2 additions & 2 deletions BWAPILIB/BWAPILIB.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{843656FD-9BFD-47BF-8460-7BFE9710EA2C}</ProjectGuid>
<RootNamespace>BWAPILIB</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -24,7 +24,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down
164 changes: 82 additions & 82 deletions Steamhammer/Source/BOSSManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ using namespace UAlbertaBot;

BOSSManager & BOSSManager::Instance()
{
static BOSSManager instance;
return instance;
static BOSSManager instance;
return instance;
}

BOSSManager::BOSSManager()
: _previousSearchStartFrame(0)
: _previousSearchStartFrame(0)
, _previousSearchFinishFrame(0)
, _searchInProgress(false)
, _previousStatus("No Searches")
Expand All @@ -35,7 +35,7 @@ void BOSSManager::startNewSearch(const std::vector<MetaPair> & goalUnits)
+ the.my.all.count(BWAPI::UnitTypes::Zerg_Lair)
+ the.my.all.count(BWAPI::UnitTypes::Zerg_Hive);

// TODO these are both solvable problems :-/
// TODO these are both solvable problems :-/
if (numWorkers == 0)
{
_previousStatus = "\x08No Workers :(";
Expand Down Expand Up @@ -66,16 +66,16 @@ void BOSSManager::startNewSearch(const std::vector<MetaPair> & goalUnits)
}
catch (const BOSS::BOSSException &)
{
if (Config::Debug::DrawBuildOrderSearchInfo)
{
BWAPI::BroodwarPtr->printf("Exception in BOSS::GameState constructor");
}
if (Config::Debug::DrawBuildOrderSearchInfo)
{
BWAPI::BroodwarPtr->printf("Exception in BOSS::GameState constructor");
}
}
}

void BOSSManager::drawSearchInformation(int x, int y)
{
if (!Config::Debug::DrawBuildOrderSearchInfo)
if (!Config::Debug::DrawBuildOrderSearchInfo)
{
return;
}
Expand Down Expand Up @@ -118,21 +118,21 @@ void BOSSManager::update(double timeLimit)
_smartSearch->setTimeLimit((int)realTimeLimit);
bool caughtException = false;

try
try
{
// call the search to continue searching
// this will resume a search in progress or start a new search if not yet started
_smartSearch->search();
}
catch (const BOSS::BOSSException &)
_smartSearch->search();
}
catch (const BOSS::BOSSException &)
{
if (Config::Debug::DrawBuildOrderSearchInfo)
{
BWAPI::Broodwar->drawTextScreen(0, 0, "Search didn't find a solution, resorting to Naive Build Order");
}
if (Config::Debug::DrawBuildOrderSearchInfo)
{
BWAPI::Broodwar->drawTextScreen(0, 0, "Search didn't find a solution, resorting to Naive Build Order");
}
_previousStatus = "BOSSExeption";
caughtException = true;
}
}

_totalPreviousSearchTime += _smartSearch->getResults().timeElapsed;

Expand All @@ -144,7 +144,7 @@ void BOSSManager::update(double timeLimit)
bool solved = _smartSearch->getResults().solved && _smartSearch->getResults().solutionFound;

// if we've found a solution, let us know
if (Config::Debug::DrawBuildOrderSearchInfo && _smartSearch->getResults().solved)
if (Config::Debug::DrawBuildOrderSearchInfo && _smartSearch->getResults().solved)
{
BWAPI::Broodwar->printf("Build order SOLVED in %d nodes", (int)_smartSearch->getResults().nodesExpanded);
}
Expand Down Expand Up @@ -190,7 +190,7 @@ void BOSSManager::update(double timeLimit)
// so try another naive build order search as a last resort
BOSS::NaiveBuildOrderSearch nbos(_smartSearch->getParameters().initialState, _smartSearch->getParameters().goal);

try
try
{
if (searchTimeOut)
{
Expand All @@ -202,23 +202,23 @@ void BOSSManager::update(double timeLimit)
_previousStatus = std::string("\x02") + "BOSS Exception\n";
}

_previousBuildOrder = nbos.solve();
_previousBuildOrder = nbos.solve();
_previousStatus += "\x03NBOS Solution";

return;
}
return;
}
// and if that search doesn't work then we're out of luck, no build orders for us
catch (const BOSS::BOSSException & exception)
catch (const BOSS::BOSSException & exception)
{
_previousStatus += "\x08Naive Exception";
if (Config::Debug::DrawBuildOrderSearchInfo)
{
UAB_ASSERT_WARNING(false, "BOSS Timeout Naive Search Exception: %s", exception.what());
BWAPI::Broodwar->drawTextScreen(0, 20, "No BuildOrder found, returning empty BuildOrder");
UAB_ASSERT_WARNING(false, "BOSS Timeout Naive Search Exception: %s", exception.what());
BWAPI::Broodwar->drawTextScreen(0, 20, "No BuildOrder found, returning empty BuildOrder");
}
_previousBuildOrder = BOSS::BuildOrder();
return;
}
_previousBuildOrder = BOSS::BuildOrder();
return;
}
}
}
}
Expand All @@ -233,14 +233,14 @@ void BOSSManager::logBadSearch()

BOSS::BuildOrderSearchGoal BOSSManager::GetGoal(const std::vector<MetaPair> & goalUnits)
{
BOSS::BuildOrderSearchGoal goal(BOSS::Races::GetRaceID(BWAPI::Broodwar->self()->getRace()));
BOSS::BuildOrderSearchGoal goal(BOSS::Races::GetRaceID(BWAPI::Broodwar->self()->getRace()));

for (size_t i=0; i<goalUnits.size(); ++i)
{
goal.setGoal(GetActionType(goalUnits[i].first), goalUnits[i].second);
}
for (size_t i=0; i<goalUnits.size(); ++i)
{
goal.setGoal(GetActionType(goalUnits[i].first), goalUnits[i].second);
}

return goal;
return goal;
}

// gets the StarcraftState corresponding to the beginning of a Melee game
Expand All @@ -249,7 +249,7 @@ BOSS::GameState BOSSManager::getStartState()
BOSS::GameState state(getRace());
state.setStartingState();

return state;
return state;
}

const BOSS::RaceID BOSSManager::getRace() const
Expand Down Expand Up @@ -282,14 +282,14 @@ bool BOSSManager::isSearchInProgress()
// converts SearchResults.buildOrder vector into vector of MacroAct
std::vector<MacroAct> BOSSManager::GetMetaVector(const BOSS::BuildOrder & buildOrder)
{
std::vector<MacroAct> metaVector;
for (size_t i(0); i<buildOrder.size(); ++i)
{
metaVector.push_back(GetMacroAct(buildOrder[i]));
}

return metaVector;
std::vector<MacroAct> metaVector;
for (size_t i(0); i<buildOrder.size(); ++i)
{
metaVector.push_back(GetMacroAct(buildOrder[i]));
}

return metaVector;
}


Expand All @@ -300,46 +300,46 @@ BuildOrder BOSSManager::getBuildOrder()

BOSS::ActionType BOSSManager::GetActionType(const MacroAct & t)
{
// set the appropriate type
if (t.isUnit())
{
return BOSS::ActionType(t.getUnitType());
}
else if (t.isUpgrade())
{
return BOSS::ActionType(t.getUpgradeType());
}
else if (t.isTech())
{
return BOSS::ActionType(t.getTechType());
}
else
{
UAB_ASSERT(false, "Should have found a valid type here");
}
return BOSS::ActionType();
// set the appropriate type
if (t.isUnit())
{
return BOSS::ActionType(t.getUnitType());
}
else if (t.isUpgrade())
{
return BOSS::ActionType(t.getUpgradeType());
}
else if (t.isTech())
{
return BOSS::ActionType(t.getTechType());
}
else
{
UAB_ASSERT(false, "Should have found a valid type here");
}
return BOSS::ActionType();
}

MacroAct BOSSManager::GetMacroAct(const BOSS::ActionType & a)
{
// set the appropriate type
if (a.isUnit())
{
return MacroAct(a.getUnitType());
}
else if (a.isUpgrade())
{
return MacroAct(a.getUpgradeType());
}
else if (a.isTech())
{
return MacroAct(a.getTechType());
}
else
{
UAB_ASSERT(false, "Should have found a valid type here");
}
return MacroAct();
// set the appropriate type
if (a.isUnit())
{
return MacroAct(a.getUnitType());
}
else if (a.isUpgrade())
{
return MacroAct(a.getUpgradeType());
}
else if (a.isTech())
{
return MacroAct(a.getTechType());
}
else
{
UAB_ASSERT(false, "Should have found a valid type here");
}
return MacroAct();
}
26 changes: 13 additions & 13 deletions Steamhammer/Source/BOSSManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,41 @@ class BOSSManager
BOSS::DFBB_BuildOrderSearchResults _savedSearchResults;
BOSS::BuildOrder _previousBuildOrder;

BOSS::GameState getCurrentState();
BOSS::GameState getStartState();
BOSS::GameState getCurrentState();
BOSS::GameState getStartState();
// functions
BOSS::DFBB_BuildOrderSearchResults search(const std::vector<MetaPair> & goalUnits);
BOSS::DFBB_BuildOrderSearchResults search(const std::vector<MetaPair> & goalUnits);

void loadOpeningBook();
void loadOpeningBook();

std::vector<std::vector<MacroAct>> openingBook;
std::vector<std::vector<MacroAct>> openingBook;
const BOSS::RaceID getRace() const;

void logBadSearch();

BOSSManager();
BOSSManager();

public:

static BOSSManager & Instance();
static BOSSManager & Instance();

void update(double timeLimit);
void update(double timeLimit);
void reset();

BuildOrder getBuildOrder();
bool isSearchInProgress();

void startNewSearch(const std::vector<MetaPair> & goalUnits);

void drawSearchInformation(int x, int y);
void drawSearchInformation(int x, int y);
void drawStateInformation(int x, int y);


static BOSS::BuildOrderSearchGoal GetGoal(const std::vector<MetaPair> & goalUnits);
static BOSS::BuildOrderSearchGoal GetGoal(const std::vector<MetaPair> & goalUnits);
static std::vector<MacroAct> GetMetaVector(const BOSS::BuildOrder & buildOrder);
static BOSS::ActionType GetActionType(const MacroAct & t);
static MacroAct GetMacroAct(const BOSS::ActionType & a);
static BOSS::ActionType GetActionType(const MacroAct & t);
static MacroAct GetMacroAct(const BOSS::ActionType & a);
};

}
Loading

0 comments on commit bb4f537

Please sign in to comment.