ProtoBot
Loading...
Searching...
No Matches
ProtoBotCommander Class Reference

The ProtoBotCommander is the main way information and BWAPI events are passed to the managers of ProtoBot. The class holds no real intelligence besides passing ResourceRequests to the StrategyManager and BuildManager of ProtoBot.
The main purpose of this class is to be able to provide a easy way for information to be passed around when needed and for each manager to process events in the defined order specified in each function, updating infromation along the way. More...

#include <ProtoBotCommander.h>

Public Member Functions

void onStart ()
void onFrame ()
void onEnd (bool isWinner)
void onUnitDestroy (BWAPI::Unit unit)
void onUnitMorph (BWAPI::Unit unit)
void onSendText (std::string text)
void onUnitCreate (BWAPI::Unit unit)
void onUnitComplete (BWAPI::Unit unit)
void onUnitShow (BWAPI::Unit unit)
void onUnitHide (BWAPI::Unit unit)
void onUnitRenegade (BWAPI::Unit unit)
void drawDebugInformation ()
void drawBuildingCount (FriendlyBuildingCounter, int x, int y, bool background=true)
void drawUnitCount (FriendlyUnitCounter, int x, int y, bool background=true)
void drawUpgradeCount (FriendlyUpgradeCounter, int x, int y, bool background=true)
void drawBwapiResourceInfo (int x, int y, bool background=true)
void removeApprovedRequests ()
void requestBuilding (BWAPI::UnitType building, bool fromBuildOrder=false, bool isWall=false, bool isRampPlacement=false, BWAPI::Position nexusPosition=BWAPI::Positions::Invalid, const BWEM::Base *baseLocation=nullptr)
void requestUnit (BWAPI::UnitType unit, BWAPI::Unit buildingToTrain, bool fromBuildOrder=false)
void requestUpgrade (BWAPI::Unit unit, BWAPI::UpgradeType upgrade, bool fromBuildOrder=false)
void requestCheese (BWAPI::UnitType, BWAPI::Unit)
void drawResourceRequestQueue (int x, int y, bool background=true)
bool upgradeAlreadyRequested (BWAPI::Unit building)
bool requestedBuilding (BWAPI::UnitType building, BWAPI::Position nexusPosition=BWAPI::Positions::Invalid)
bool checkUnitIsBeingWarpedIn (BWAPI::UnitType type, const BWEM::Base *nexus=nullptr)
bool checkUnitIsPlanned (BWAPI::UnitType building, BWAPI::Position nexusPosition=BWAPI::Positions::Invalid)
bool checkCheeseRequest (BWAPI::Unit)
bool alreadySentRequest (int unitID)
BWAPI::Unit getUnitToBuild (BWAPI::Position buildLocation)
std::vector< NexusEconomygetNexusEconomies ()
const std::set< BWAPI::Unit > & getKnownEnemyUnits ()
const std::map< BWAPI::Unit, EnemyBuildingInfo > & getKnownEnemyBuildings ()
const EnemyLocationsenemy () const
EnemyLocationsenemy ()
void onEnemyMainFound (const BWAPI::TilePosition &tp)
void onEnemyNaturalFound (const BWAPI::TilePosition &tp)
int getEnemyGroundThreatAt (BWAPI::Position p) const
int getEnemyDetectionAt (BWAPI::Position p) const
ThreatQueryResult queryThreatAt (const BWAPI::Position &pos) const
bool isAirThreatened (const BWAPI::Position &pos, int threshold) const
bool isDetectorThreatened (const BWAPI::Position &pos) const
bool buildOrderCompleted ()
bool checkWorkerIsConstructing (BWAPI::Unit)
BWAPI::Unit getUnitToScout ()
bool shouldGasSteal ()

Public Attributes

MapTools m_mapTools
TimerManager timerManager
EconomyManager economyManager
ScoutingManager scoutingManager
BuildManager buildManager
CombatManager combatManager
StrategyManager strategyManager
ProtoBotRequestCounter requestCounter
bool drawUnitDebug = false
bool drawBWEBDebug = false
bool drawToolsDebug = false
int requestCount = 0
std::vector< ResourceRequestresourceRequests

Private Attributes

EnemyLocations enemy_

Detailed Description

The ProtoBotCommander is the main way information and BWAPI events are passed to the managers of ProtoBot. The class holds no real intelligence besides passing ResourceRequests to the StrategyManager and BuildManager of ProtoBot.
The main purpose of this class is to be able to provide a easy way for information to be passed around when needed and for each manager to process events in the defined order specified in each function, updating infromation along the way.

Definition at line 133 of file ProtoBotCommander.h.

Constructor & Destructor Documentation

◆ ProtoBotCommander()

ProtoBotCommander::ProtoBotCommander ( )

Definition at line 4 of file ProtoBotCommander.cpp.

4 : buildManager(this), strategyManager(this), economyManager(this), scoutingManager(this), combatManager(this)
5{
6 // Initialize singleton InformationManager with this commander reference
7 InformationManager::Instance().SetCommander(this);
8
9}

Member Function Documentation

◆ alreadySentRequest()

bool ProtoBotCommander::alreadySentRequest ( int unitID)

Definition at line 641 of file ProtoBotCommander.cpp.

642{
643 for (const ResourceRequest& request : resourceRequests)
644 {
645 if (request.type == ResourceRequest::Type::Unit && request.requestedBuilding != nullptr)
646 {
647 if (unitID == request.requestedBuilding->getID()) return true;
648 }
649 }
650 return false;
651}

◆ buildOrderCompleted()

bool ProtoBotCommander::buildOrderCompleted ( )

Definition at line 888 of file ProtoBotCommander.cpp.

889{
890 return buildManager.isBuildOrderCompleted();
891}

◆ checkCheeseRequest()

bool ProtoBotCommander::checkCheeseRequest ( BWAPI::Unit unit)

Definition at line 876 of file ProtoBotCommander.cpp.

877{
878 for (ResourceRequest& request : resourceRequests)
879 {
880 if (request.type != ResourceRequest::Type::Building && request.isCheese) continue;
881
882 if (request.scoutToPlaceBuilding == unit && request.state == ResourceRequest::State::Approved_BeingBuilt) return true;
883 }
884
885 return false;
886}

◆ checkUnitIsBeingWarpedIn()

bool ProtoBotCommander::checkUnitIsBeingWarpedIn ( BWAPI::UnitType type,
const BWEM::Base * nexus = nullptr )

Definition at line 842 of file ProtoBotCommander.cpp.

843{
844 return buildManager.checkUnitIsBeingWarpedIn(building, nexus);
845}

◆ checkUnitIsPlanned()

bool ProtoBotCommander::checkUnitIsPlanned ( BWAPI::UnitType building,
BWAPI::Position nexusPosition = BWAPI::Positions::Invalid )

Definition at line 679 of file ProtoBotCommander.cpp.

680{
681 for (const ResourceRequest& request : resourceRequests)
682 {
683 if (building == request.unit
684 && (request.state == ResourceRequest::State::Approved_InProgress || request.state == ResourceRequest::State::PendingApproval || request.state == ResourceRequest::State::Approved_BeingBuilt)
685 && request.nexusPositionRef == nexusPosition
686 && !request.isCheese)
687 {
688 //if (request.nexusPositionRef != BWAPI::Positions::Invalid) std::cout << "Nexus at " << request.nexusPositionRef << " already has assimilator planned\n";
689
690 return true;
691 }
692 }
693 return false;
694}

◆ checkWorkerIsConstructing()

bool ProtoBotCommander::checkWorkerIsConstructing ( BWAPI::Unit unit)

Definition at line 898 of file ProtoBotCommander.cpp.

899{
900 return buildManager.checkWorkerIsConstructing(unit);
901}

◆ drawBuildingCount()

void ProtoBotCommander::drawBuildingCount ( FriendlyBuildingCounter ProtoBot_buildingCount,
int x,
int y,
bool background = true )

Definition at line 764 of file ProtoBotCommander.cpp.

765{
766 if (background) BWAPI::Broodwar->drawBoxScreen(x - 5, y - 5, x + 150, y + 115, BWAPI::Colors::Black, true);
767
768 BWAPI::Broodwar->drawTextScreen(x, y, "%cCurrent Building Count", BWAPI::Text::White);
769 BWAPI::Broodwar->drawTextScreen(x, y + 1, "%c________________________", BWAPI::Text::White);
770 BWAPI::Broodwar->drawTextScreen(x, y + 10, "%cPylon = %d", BWAPI::Text::White, ProtoBot_buildingCount.pylon);
771 BWAPI::Broodwar->drawTextScreen(x, y + 20, "%cNexus = %d", BWAPI::Text::White, ProtoBot_buildingCount.nexus);
772 BWAPI::Broodwar->drawTextScreen(x, y + 30, "%cGateway = %d", BWAPI::Text::White, ProtoBot_buildingCount.gateway);
773 BWAPI::Broodwar->drawTextScreen(x, y + 40, "%cForge = %d", BWAPI::Text::White, ProtoBot_buildingCount.forge);
774 BWAPI::Broodwar->drawTextScreen(x, y + 50, "%cCybernetics Core = %d", BWAPI::Text::White, ProtoBot_buildingCount.cyberneticsCore);
775 BWAPI::Broodwar->drawTextScreen(x, y + 60, "%cPhoton Can. = %d", BWAPI::Text::White, ProtoBot_buildingCount.photonCannon);
776 BWAPI::Broodwar->drawTextScreen(x, y + 70, "%cRobotics Facil. = %d", BWAPI::Text::White, ProtoBot_buildingCount.roboticsFacility);
777 BWAPI::Broodwar->drawTextScreen(x, y + 80, "%cCitadel of Adun = %d", BWAPI::Text::White, ProtoBot_buildingCount.citadelOfAdun);
778 BWAPI::Broodwar->drawTextScreen(x, y + 90, "%cObservatory = %d", BWAPI::Text::White, ProtoBot_buildingCount.observatory);
779 BWAPI::Broodwar->drawTextScreen(x, y + 100, "%cTemplar Arch. = %d", BWAPI::Text::White, ProtoBot_buildingCount.templarArchives);
780}

◆ drawBwapiResourceInfo()

void ProtoBotCommander::drawBwapiResourceInfo ( int x,
int y,
bool background = true )

Definition at line 796 of file ProtoBotCommander.cpp.

797{
798 if(background) BWAPI::Broodwar->drawBoxScreen(x - 5, y - 5, x + 200, y + 55, BWAPI::Colors::Black, true);
799
800 BWAPI::Broodwar->drawTextScreen(x, y, "%cBWAPI Resource Information", BWAPI::Text::White);
801 BWAPI::Broodwar->drawTextScreen(x, y + 1, "%c________________________________", BWAPI::Text::White);
802 BWAPI::Broodwar->drawTextScreen(x, y + 10, "%cTotal Minerals Gathered: %d", BWAPI::Text::White, BWAPI::Broodwar->self()->gatheredMinerals());
803 BWAPI::Broodwar->drawTextScreen(x, y + 20, "%cTotal Gas Gathered : %d", BWAPI::Text::White, BWAPI::Broodwar->self()->gatheredGas());
804 BWAPI::Broodwar->drawTextScreen(x, y + 30, "%cTotal Minerals Spent: %d", BWAPI::Text::White, BWAPI::Broodwar->self()->spentMinerals());
805 BWAPI::Broodwar->drawTextScreen(x, y + 40, "%cTotal Gas Spent : %d", BWAPI::Text::White, BWAPI::Broodwar->self()->spentGas());
806}

◆ drawDebugInformation()

void ProtoBotCommander::drawDebugInformation ( )

Definition at line 808 of file ProtoBotCommander.cpp.

809{
810 // Display the game frame rate as text in the upper left area of the screen
811 BWAPI::Broodwar->drawTextScreen(5, 5, "%cFrame: %d", BWAPI::Text::White, BWAPI::Broodwar->getFrameCount());
812 BWAPI::Broodwar->drawTextScreen(100, 5, "%cFPS: %d", BWAPI::Text::White, BWAPI::Broodwar->getFPS());
813 BWAPI::Broodwar->drawTextScreen(170, 5, "%cOpponent Race: %s", BWAPI::Text::White, strategyManager.opponentRace.c_str());
814
815 if (drawUnitDebug)
816 {
817 //Need to find a place to put this on the screen, might need to have a /command to get the stuff I need.
818 drawBwapiResourceInfo(5, 180);
819
820 drawBuildingCount(InformationManager::Instance().getFriendlyBuildingCounter(), 490, 30);
821 drawUpgradeCount(InformationManager::Instance().getFriendlyUpgradeCounter(), 490, 152);
822 drawUnitCount(InformationManager::Instance().getFriendlyUnitCounter(), 5, 105);
823 timerManager.displayTimers(490, 225);
824 strategyManager.drawGameUnitProduction(strategyManager.unitProductionCounter, 5, 30);
825 }
826 else if (drawBWEBDebug)
827 {
828 BWEB::Map::draw();
829 }
830 else if (drawToolsDebug)
831 {
832 Tools::DrawUnitCommands();
833 Tools::DrawUnitBoundingBoxes();
834 }
835 else if (strategyManager.drawStrategyDebug)
836 {
837 drawResourceRequestQueue(2, 35);
838 }
839}

◆ drawResourceRequestQueue()

void ProtoBotCommander::drawResourceRequestQueue ( int x,
int y,
bool background = true )

Definition at line 696 of file ProtoBotCommander.cpp.

697{
698 if (background) BWAPI::Broodwar->drawBoxScreen(x - 5, y - 5, x + 270, y + 130, BWAPI::Colors::Black, true);
699 BWAPI::Broodwar->drawTextScreen(x + 5, y - 3, "%cResource Request Queue", BWAPI::Text::White);
700 BWAPI::Broodwar->drawTextScreen(x + 5, y + -2, "%c___________________________________________", BWAPI::Text::White);
701 BWAPI::Broodwar->drawTextScreen(x + 5, y + 10, "%c %2s | %-10s | %4s | %4s | %14s", BWAPI::Text::White, "#", "Type", "Min", "Gas", "Frame Approved");
702 BWAPI::Broodwar->drawTextScreen(x + 5, y + 14, "%c___________________________________________", BWAPI::Text::White);
703
704 const int min_y = y + 15;
705 for (size_t iter = 0; iter < 10; iter++)
706 {
707 if (iter < resourceRequests.size())
708 {
709 const ResourceRequest request = resourceRequests.at(iter);
710
711 const ResourceRequest::Type request_type = request.type;
712 int mineralCost = -1;
713 int gasCost = -1;
714 std::string type_string;
715 std::string frame_string = (request.frameRequestApproved == -1 ? "N\\A" : std::to_string(request.frameRequestApproved));
716
717 switch (request_type)
718 {
719 case ResourceRequest::Unit:
720 type_string = "Unit";
721 mineralCost = request.unit.mineralPrice();
722 gasCost = request.unit.gasPrice();
723 break;
724 case ResourceRequest::Building:
725 type_string = "Building";
726 mineralCost = request.unit.mineralPrice();
727 gasCost = request.unit.gasPrice();
728 break;
729 case ResourceRequest::Upgrade:
730 type_string = "Upgrade";
731 mineralCost = request.upgrade.mineralPrice();
732 gasCost = request.upgrade.gasPrice();
733 break;
734 case ResourceRequest::Tech:
735 type_string = "Tech";
736 mineralCost = request.tech.mineralPrice();
737 gasCost = request.tech.gasPrice();
738 break;
739 }
740 BWAPI::Broodwar->drawTextScreen(x, min_y + ((iter + 1) * 10), "%c %2d %-10s %4d %4d %6s", BWAPI::Text::White, iter + 1, type_string.c_str(), mineralCost, gasCost, frame_string.c_str());
741 }
742 else
743 {
744 BWAPI::Broodwar->drawTextScreen(x, min_y + ((iter + 1) * 10), "%c %2d %-10s %4d %4d %6s", BWAPI::Text::White, iter + 1, "None", 0, 0, "N\\A");
745 }
746 }
747}

◆ drawUnitCount()

void ProtoBotCommander::drawUnitCount ( FriendlyUnitCounter ProtoBot_unitCount,
int x,
int y,
bool background = true )

Definition at line 750 of file ProtoBotCommander.cpp.

751{
752 if (background) BWAPI::Broodwar->drawBoxScreen(x - 5, y - 5, x + 150, y + 65, BWAPI::Colors::Black, true);
753 BWAPI::Broodwar->drawTextScreen(x, y, "%cCurrent Unit Count", BWAPI::Text::White);
754 BWAPI::Broodwar->drawTextScreen(x, y + 1, "%c________________________", BWAPI::Text::White);
755 BWAPI::Broodwar->drawTextScreen(x, y + 10, "%cWorkers = %d", BWAPI::Text::White, ProtoBot_unitCount.probe);
756 BWAPI::Broodwar->drawTextScreen(x, y + 20, "%cZealots = %d", BWAPI::Text::White, ProtoBot_unitCount.zealot);
757 BWAPI::Broodwar->drawTextScreen(x, y + 30, "%cDragoons = %d", BWAPI::Text::White, ProtoBot_unitCount.dragoon);
758 BWAPI::Broodwar->drawTextScreen(x, y + 40, "%cObservers = %d", BWAPI::Text::White, ProtoBot_unitCount.observer);
759 BWAPI::Broodwar->drawTextScreen(x, y + 50, "%cDark Templars = %d", BWAPI::Text::White, ProtoBot_unitCount.darkTemplar);
760
761}

◆ drawUpgradeCount()

void ProtoBotCommander::drawUpgradeCount ( FriendlyUpgradeCounter ProtoBot_upgradeCount,
int x,
int y,
bool background = true )

Definition at line 783 of file ProtoBotCommander.cpp.

784{
785 if (background) BWAPI::Broodwar->drawBoxScreen(x - 5, y - 5, x + 150, y + 65, BWAPI::Colors::Black, true);
786
787 BWAPI::Broodwar->drawTextScreen(x, y, "%cCurrent Upgrade Count", BWAPI::Text::White);
788 BWAPI::Broodwar->drawTextScreen(x, y + 1, "%c________________________", BWAPI::Text::White);
789 BWAPI::Broodwar->drawTextScreen(x, y + 10, "%cDragoon Range = %s", BWAPI::Text::White, (ProtoBot_upgradeCount.singularityCharge ? "true" : "false"));
790 BWAPI::Broodwar->drawTextScreen(x, y + 20, "%cGround Weapons = %d", BWAPI::Text::White, ProtoBot_upgradeCount.groundWeapons);
791 BWAPI::Broodwar->drawTextScreen(x, y + 30, "%cGround Armor = %d", BWAPI::Text::White, ProtoBot_upgradeCount.groundArmor);
792 BWAPI::Broodwar->drawTextScreen(x, y + 40, "%cPlasma Shields = %d", BWAPI::Text::White, ProtoBot_upgradeCount.plasmaShields);
793 BWAPI::Broodwar->drawTextScreen(x, y + 50, "%cLeg Enhance. = %d", BWAPI::Text::White, ProtoBot_upgradeCount.legEnhancements);
794}

◆ enemy() [1/2]

EnemyLocations & ProtoBotCommander::enemy ( )
inline

Definition at line 202 of file ProtoBotCommander.h.

202{ return enemy_; }

◆ enemy() [2/2]

const EnemyLocations & ProtoBotCommander::enemy ( ) const
inline

Definition at line 201 of file ProtoBotCommander.h.

201{ return enemy_; }

◆ getEnemyDetectionAt()

int ProtoBotCommander::getEnemyDetectionAt ( BWAPI::Position p) const

Definition at line 1011 of file ProtoBotCommander.cpp.

1011 {
1012 return InformationManager::Instance().getEnemyDetectionAt(p);
1013}

◆ getEnemyGroundThreatAt()

int ProtoBotCommander::getEnemyGroundThreatAt ( BWAPI::Position p) const

Definition at line 1007 of file ProtoBotCommander.cpp.

1007 {
1008 return InformationManager::Instance().getEnemyGroundThreatAt(p);
1009}

◆ getKnownEnemyBuildings()

const std::map< BWAPI::Unit, EnemyBuildingInfo > & ProtoBotCommander::getKnownEnemyBuildings ( )

Definition at line 858 of file ProtoBotCommander.cpp.

859{
860 return InformationManager::Instance().getKnownEnemyBuildings();
861}

◆ getKnownEnemyUnits()

const std::set< BWAPI::Unit > & ProtoBotCommander::getKnownEnemyUnits ( )

Definition at line 853 of file ProtoBotCommander.cpp.

854{
855 return InformationManager::Instance().getKnownEnemies();
856}

◆ getNexusEconomies()

std::vector< NexusEconomy > ProtoBotCommander::getNexusEconomies ( )

Definition at line 893 of file ProtoBotCommander.cpp.

894{
895 return economyManager.getNexusEconomies();
896}

◆ getUnitToBuild()

BWAPI::Unit ProtoBotCommander::getUnitToBuild ( BWAPI::Position buildLocation)

Definition at line 847 of file ProtoBotCommander.cpp.

848{
849 //Will not check for null, we expect to get a unit that is able to build. We may also be able to add a command once they return a mineral.
850 return economyManager.getAvalibleWorker(buildLocation);
851}

◆ getUnitToScout()

BWAPI::Unit ProtoBotCommander::getUnitToScout ( )

Definition at line 906 of file ProtoBotCommander.cpp.

907{
908 auto isValidUnit = [](BWAPI::Unit u)
909 {
910 return u && u->exists() && u->getPlayer() == BWAPI::Broodwar->self() && !u->getType().isBuilding();
911 };
912
913 const int frame = BWAPI::Broodwar->getFrameCount();
914
915 if (frame >= kCombatScoutFrame && !scoutingManager.combatScoutingStarted())
916 {
917 scoutingManager.setCombatScoutingStarted(true);
918 }
919
920 // Before combat scouting: keep exactly one worker scout
921 if (!scoutingManager.combatScoutingStarted())
922 {
923 if (scoutingManager.canAcceptWorkerScout())
924 {
925 BWAPI::Unit w = economyManager.getUnitScout();
926 if (isValidUnit(w))
927 {
928 scoutingManager.assignScout(w);
929 return w;
930 }
931 }
932
933 return nullptr;
934 }
935
936 // After combat scouting starts, assign at most one scout per call.
937
938 if (scoutingManager.canAcceptCombatScout(BWAPI::UnitTypes::Protoss_Zealot))
939 {
940 BWAPI::Unit u = combatManager.getAvailableUnit(
941 [](BWAPI::Unit x)
942 {
943 return x && x->exists() && x->getPlayer() == BWAPI::Broodwar->self() && x->getType() == BWAPI::UnitTypes::Protoss_Zealot;
944 }
945 );
946
947 if (isValidUnit(u))
948 {
949 scoutingManager.assignScout(u);
950 return u;
951 }
952 }
953
954 if (scoutingManager.canAcceptCombatScout(BWAPI::UnitTypes::Protoss_Dragoon))
955 {
956 BWAPI::Unit u = combatManager.getAvailableUnit(
957 [](BWAPI::Unit x)
958 {
959 return x && x->exists() && x->getPlayer() == BWAPI::Broodwar->self() && x->getType() == BWAPI::UnitTypes::Protoss_Dragoon;
960 }
961 );
962
963 if (isValidUnit(u))
964 {
965 //std::cout << "Assigning Dragoon to scout\n";
966 scoutingManager.assignScout(u);
967 return u;
968 }
969 }
970
971 if (scoutingManager.canAcceptObserverScout())
972 {
973 BWAPI::Unit u = combatManager.getAvailableUnit(
974 [](BWAPI::Unit x)
975 {
976 return x && x->exists() && x->getPlayer() == BWAPI::Broodwar->self() && x->getType() == BWAPI::UnitTypes::Protoss_Observer;
977 }
978 );
979
980 if (isValidUnit(u))
981 {
982 scoutingManager.assignScout(u);
983 return u;
984 }
985 }
986
987 return nullptr;
988}

◆ isAirThreatened()

bool ProtoBotCommander::isAirThreatened ( const BWAPI::Position & pos,
int threshold ) const

Definition at line 1020 of file ProtoBotCommander.cpp.

1021{
1022 const auto r = queryThreatAt(pos);
1023 return r.airThreat >= threshold;
1024}

◆ isDetectorThreatened()

bool ProtoBotCommander::isDetectorThreatened ( const BWAPI::Position & pos) const

Definition at line 1026 of file ProtoBotCommander.cpp.

1027{
1028 const auto r = queryThreatAt(pos);
1029 return r.detectorThreat > 0;
1030}

◆ onEnd()

void ProtoBotCommander::onEnd ( bool isWinner)

Definition at line 156 of file ProtoBotCommander.cpp.

157{
158 // Important: Clear all caches BWEB pointers upon game end, otherwise invalid = crash
159 BWEB::Map::onEnd();
160}

◆ onEnemyMainFound()

void ProtoBotCommander::onEnemyMainFound ( const BWAPI::TilePosition & tp)

Definition at line 991 of file ProtoBotCommander.cpp.

991 {
992 enemy_.main = tp;
993 enemy_.frameLastUpdateMain = BWAPI::Broodwar->getFrameCount();
994 //BWAPI::Broodwar->printf("[Commander] Enemy main set to (%d,%d)", tp.x, tp.y);
995
996 // StrategyManager.onEnemyMain(tp);
997}

◆ onEnemyNaturalFound()

void ProtoBotCommander::onEnemyNaturalFound ( const BWAPI::TilePosition & tp)

Definition at line 999 of file ProtoBotCommander.cpp.

999 {
1000 enemy_.natural = tp;
1001 enemy_.frameLastUpdateNat = BWAPI::Broodwar->getFrameCount();
1002 //BWAPI::Broodwar->printf("[Commander] Enemy natural set to (%d,%d)", tp.x, tp.y);
1003
1004 // StrategyManager.onEnemyNaturalFound(tp)
1005}

◆ onFrame()

void ProtoBotCommander::onFrame ( )

Definition at line 76 of file ProtoBotCommander.cpp.

77{
78 // Draw unit health bars, which brood war unfortunately does not do
79 Tools::DrawUnitHealthBars();
80
81 // Draw some relevent information to the screen to help us debug the bot
82 drawDebugInformation();
83
84 removeApprovedRequests();
85
86 /*
87 * Do not touch this code, these are lines of code from StarterBot that we need to have our bot functioning.
88 */
89 timerManager.startTimer(TimerManager::All);
90
91 // Update our MapTools information
92 timerManager.startTimer(TimerManager::MapTools);
93 m_mapTools.onFrame();
94 timerManager.stopTimer(TimerManager::MapTools);
95
96 /*
97 * Protobot Modules
98 */
99
100 timerManager.startTimer(TimerManager::Information);
101 InformationManager::Instance().onFrame();
102 timerManager.stopTimer(TimerManager::Information);
103
104 timerManager.startTimer(TimerManager::Economy);
105 economyManager.onFrame();
106 timerManager.stopTimer(TimerManager::Economy);
107
108 timerManager.startTimer(TimerManager::Strategy);
109 std::vector<Action> actions = strategyManager.onFrame(resourceRequests);
110
111 bool issuedScoutThisFrame = false;
112
113 for (const Action& action : actions)
114 {
115 switch (action.type)
116 {
117 case Action::ACTION_SCOUT:
118 if (!issuedScoutThisFrame)
119 {
120 BWAPI::Unit scout = getUnitToScout();
121 if (scout)
122 {
123 issuedScoutThisFrame = true;
124 }
125 }
126 break;
127 case Action::ACTION_ATTACK:
128 combatManager.attack(action.attackPosition);
129 break;
130 case Action::ACTION_DEFEND:
131 combatManager.defend(action.defendPosition);
132 break;
133 case Action::ACTION_REINFORCE:
134 combatManager.reinforce(action.reinforcePosition);
135 break;
136 }
137 }
138 timerManager.stopTimer(TimerManager::Strategy);
139
140 timerManager.startTimer(TimerManager::Build);
141 buildManager.onFrame(resourceRequests);
142 timerManager.stopTimer(TimerManager::Build);
143
144 //Uncomment this once onFrame does not steal a worker.
145 timerManager.startTimer(TimerManager::Scouting);
146 scoutingManager.onFrame();
147 timerManager.stopTimer(TimerManager::Scouting);
148
149 timerManager.startTimer(TimerManager::Combat);
150 combatManager.onFrame();
151 timerManager.stopTimer(TimerManager::Combat);
152
153 timerManager.stopTimer(TimerManager::All);
154}

◆ onSendText()

void ProtoBotCommander::onSendText ( std::string text)

Definition at line 222 of file ProtoBotCommander.cpp.

223{
224 if (text == "/map")
225 {
226 m_mapTools.toggleDraw();
227 }
228
229 if (text == "/combat")
230 {
231 drawUnitDebug = false;
232 strategyManager.drawStrategyDebug = false;
233 scoutingManager.scoutingDebugEnabled_ = false;
234 combatManager.combat_debug_on = true;
235 drawBWEBDebug = false;
236 drawToolsDebug = false;
237 }
238 else if (text == "/scout")
239 {
240 drawUnitDebug = false;
241 strategyManager.drawStrategyDebug = false;
242 scoutingManager.scoutingDebugEnabled_ = true;
243 combatManager.combat_debug_on = false;
244 drawBWEBDebug = false;
245 drawToolsDebug = false;
246 }
247 else if (text == "/build")
248 {
249 drawUnitDebug = false;
250 strategyManager.drawStrategyDebug = false;
251 scoutingManager.scoutingDebugEnabled_ = false;
252 combatManager.combat_debug_on = false;
253 drawBWEBDebug = true;
254 drawToolsDebug = false;
255 }
256 else if (text == "/strat")
257 {
258 drawUnitDebug = false;
259 strategyManager.drawStrategyDebug = true;
260 scoutingManager.scoutingDebugEnabled_ = false;
261 combatManager.combat_debug_on = false;
262 drawBWEBDebug = false;
263 drawToolsDebug = false;
264 }
265 else if (text == "/info")
266 {
267 drawUnitDebug = true;
268 strategyManager.drawStrategyDebug = false;
269 scoutingManager.scoutingDebugEnabled_ = false;
270 combatManager.combat_debug_on = false;
271 drawBWEBDebug = false;
272 drawToolsDebug = false;
273 }
274 else if (text == "/tools")
275 {
276 drawUnitDebug = false;
277 strategyManager.drawStrategyDebug = false;
278 scoutingManager.scoutingDebugEnabled_ = false;
279 combatManager.combat_debug_on = false;
280 drawBWEBDebug = false;
281 drawToolsDebug = true;
282 }
283 else if (text == "/off")
284 {
285 drawUnitDebug = false;
286 strategyManager.drawStrategyDebug = false;
287 scoutingManager.scoutingDebugEnabled_ = false;
288 combatManager.combat_debug_on = false;
289 drawBWEBDebug = false;
290 drawToolsDebug = false;
291 }
292}

◆ onStart()

void ProtoBotCommander::onStart ( )

Definition at line 12 of file ProtoBotCommander.cpp.

13{
14 //std::cout << "============================\n";
15 //std::cout << "Initializing Modules\n";
16
17 /*
18 * Do not touch this code, these are lines of code from StarterBot that we need to have our bot functioning.
19 */
20
21 // Set our BWAPI options here
22 BWAPI::Broodwar->setLocalSpeed(10);
23 BWAPI::Broodwar->setFrameSkip(0);
24
25 // Enable the flag that tells BWAPI to let users enter input while bot plays
26 BWAPI::Broodwar->enableFlag(BWAPI::Flag::UserInput);
27
28 static bool mapInitialized = false;
29
30 //std::cout << "Map initialization...\n";
31
32 //theMap = BWEM::Map::Instance();
33 theMap.Initialize();
34 theMap.EnableAutomaticPathAnalysis();
35 bool startingLocationsOK = theMap.FindBasesForStartingLocations();
36 assert(startingLocationsOK);
37
38 BWEB::Map::onStart();
39 BWEB::Blocks::findBlocks();
40
41 m_mapTools.onStart();
42
43 const BWAPI::Unitset units = BWAPI::Broodwar->self()->getUnits();
44
45 economyManager.onStart();
46
47 //Get nexus and create a new instace of a NexusEconomy
48 //Need to do this because when units are created at the beggining of the game a nexus economy does not exist.
49 for (BWAPI::Unit unit : units)
50 {
51 if (unit->getType() == BWAPI::UnitTypes::Protoss_Nexus)
52 {
53 economyManager.assignUnit(unit);
54 }
55 }
56
57 /*
58 * Protobot Modules
59 */
60 InformationManager::Instance().onStart();
61 strategyManager.onStart();
62 scoutingManager.onStart();
63 buildManager.onStart();
64 combatManager.onStart();
65
66 resourceRequests.clear();
67
68 ProtoBotRequestCounter newRequestCounter;
69 requestCounter = newRequestCounter;
70
71 requestCount = 0;
72 //std::cout << "============================\n";
73 //std::cout << "Agent Start\n";
74}

◆ onUnitComplete()

void ProtoBotCommander::onUnitComplete ( BWAPI::Unit unit)

Definition at line 381 of file ProtoBotCommander.cpp.

382{
383 //std::cout << "ProtoBot onUnitComplete: " << unit->getType() << "\n";
384
385 strategyManager.onUnitComplete(unit);
386 InformationManager::Instance().onUnitComplete(unit);
387
388 if (unit->getPlayer() != BWAPI::Broodwar->self()) return;
389
390 const BWAPI::UnitType unit_type = unit->getType();
391
392 //We will let the Ecconomy Manager exclusivly deal with all ecconomy units (Nexus, Assimilator, Probe).
393 if (unit_type == BWAPI::UnitTypes::Protoss_Nexus || unit_type == BWAPI::UnitTypes::Protoss_Assimilator || unit_type == BWAPI::UnitTypes::Protoss_Probe)
394 {
395 //std::cout << "Calling onComplete for " << unit_type << " " << unit->getID() << "\n";
396 economyManager.assignUnit(unit);
397 buildManager.onUnitComplete(unit);
398 return;
399 }
400
401 if (unit_type.isBuilding())
402 {
403 //std::cout << "Calling onComplete for " << unit_type << " " << unit->getID() << "\n";
404 buildManager.onUnitComplete(unit);
405 return;
406 }
407
408 if (unit_type == BWAPI::UnitTypes::Protoss_Observer)
409 {
410 if (scoutingManager.canAcceptObserverScout())
411 {
412 scoutingManager.assignScout(unit);
413 //BWAPI::Broodwar->printf("[Commander] Assigned Observer %d to Scouting", unit->getID());
414 return;
415 }
416 }
417
418 if (unit_type == BWAPI::UnitTypes::Protoss_Dark_Templar)
419 {
420 scoutingManager.assignScout(unit);
421 return;
422 }
423
424 //Gone through all cases assume it is a combat unit
425 combatManager.assignUnit(unit);
426}

◆ onUnitCreate()

void ProtoBotCommander::onUnitCreate ( BWAPI::Unit unit)

Definition at line 294 of file ProtoBotCommander.cpp.

295{
296 if (unit == nullptr) return;
297
298 buildManager.onUnitCreate(unit);
299 InformationManager::Instance().onUnitCreate(unit);
300 strategyManager.onUnitCreate(unit);
301
302 //Update requests
303 if (unit->getPlayer() == BWAPI::Broodwar->self())
304 {
305 for (ResourceRequest& request : resourceRequests)
306 {
307 if (request.state == ResourceRequest::State::Approved_BeingBuilt &&
308 request.unit == unit->getType())
309 {
310 request.state = ResourceRequest::State::Accepted_Completed;
311 }
312 }
313 }
314
315 if (unit->getPlayer() == BWAPI::Broodwar->self())
316 {
317 switch (unit->getType())
318 {
319 case BWAPI::UnitTypes::Protoss_Pylon:
320 if (requestCounter.pylons_requests > 0)
321 --requestCounter.pylons_requests;
322 break;
323 case BWAPI::UnitTypes::Protoss_Gateway:
324 if (requestCounter.gateway_requests > 0)
325 --requestCounter.gateway_requests;
326 break;
327 case BWAPI::UnitTypes::Protoss_Nexus:
328 if (requestCounter.nexus_requests > 0)
329 --requestCounter.nexus_requests;
330 break;
331 case BWAPI::UnitTypes::Protoss_Forge:
332 if (requestCounter.forge_requests > 0)
333 --requestCounter.forge_requests;
334 break;
335 case BWAPI::UnitTypes::Protoss_Cybernetics_Core:
336 if (requestCounter.cybernetics_requests > 0)
337 --requestCounter.cybernetics_requests;
338 break;
339 case BWAPI::UnitTypes::Protoss_Robotics_Facility:
340 if (requestCounter.robotics_requests > 0)
341 --requestCounter.robotics_requests;
342 break;
343 case BWAPI::UnitTypes::Protoss_Observatory:
344 if (requestCounter.observatory_requests > 0)
345 --requestCounter.observatory_requests;
346 break;
347 case BWAPI::UnitTypes::Protoss_Citadel_of_Adun:
348 if (requestCounter.citadel_requests > 0)
349 --requestCounter.citadel_requests;
350 break;
351 case BWAPI::UnitTypes::Protoss_Templar_Archives:
352 if (requestCounter.templarArchives_requests > 0)
353 --requestCounter.templarArchives_requests;
354 break;
355 case BWAPI::UnitTypes::Protoss_Probe:
356 if(requestCounter.worker_requests > 0)
357 --requestCounter.worker_requests;
358 break;
359 case BWAPI::UnitTypes::Protoss_Zealot:
360 if (requestCounter.zealots_requests > 0)
361 --requestCounter.zealots_requests;
362 break;
363 case BWAPI::UnitTypes::Protoss_Dragoon:
364 if (requestCounter.dragoons_requests > 0)
365 --requestCounter.dragoons_requests;
366 break;
367 case BWAPI::UnitTypes::Protoss_Observer:
368 if (requestCounter.observers_requests > 0)
369 --requestCounter.observers_requests;
370 break;
371 case BWAPI::UnitTypes::Protoss_Dark_Templar:
372 if (requestCounter.dark_templars_requests > 0)
373 --requestCounter.dark_templars_requests;
374 break;
375 default:
376 break;
377 }
378 }
379}

◆ onUnitDestroy()

void ProtoBotCommander::onUnitDestroy ( BWAPI::Unit unit)

Definition at line 167 of file ProtoBotCommander.cpp.

168{
169 //Managers that deal with unit assignments
170 economyManager.onUnitDestroy(unit);
171 combatManager.onUnitDestroy(unit);
172 scoutingManager.onUnitDestroy(unit);
173
174 //Managers that deal with unit information updates
175 strategyManager.onUnitDestroy(unit);
176 InformationManager::Instance().onUnitDestroy(unit);
177 buildManager.onUnitDestroy(unit);
178}

◆ onUnitHide()

void ProtoBotCommander::onUnitHide ( BWAPI::Unit unit)

Definition at line 433 of file ProtoBotCommander.cpp.

434{
435
436}

◆ onUnitMorph()

void ProtoBotCommander::onUnitMorph ( BWAPI::Unit unit)

Definition at line 180 of file ProtoBotCommander.cpp.

181{
182 InformationManager::Instance().onUnitMorph(unit);
183
184 //Remove unit from resource requests. Refinery sends an onUnitMorph event not a seperate onCreate/onComplete event
185 if (unit->getPlayer() == BWAPI::Broodwar->self())
186 {
187 for (ResourceRequest& request : resourceRequests)
188 {
189 if (request.base != nullptr)
190 {
191 if (request.state == ResourceRequest::State::Approved_BeingBuilt &&
192 request.unit == unit->getType())
193 {
194 for (const BWEM::Geyser* geyer : request.base->Geysers())
195 {
196 if (unit->getPosition() == geyer->Pos())
197 {
198 request.state = ResourceRequest::State::Accepted_Completed;
199
200 }
201 }
202 }
203 }
204 else
205 {
206 //Request is cheese most likely
207 if (request.state == ResourceRequest::State::Approved_BeingBuilt &&
208 request.unit == unit->getType() &&
209 request.base == nullptr)
210 {
211 request.state = ResourceRequest::State::Accepted_Completed;
212 //std::cout << "Assimilator with no base assigned set to complete\n";
213 }
214 }
215 }
216 }
217
218 //Remove builder
219 buildManager.onUnitMorph(unit);
220}

◆ onUnitRenegade()

void ProtoBotCommander::onUnitRenegade ( BWAPI::Unit unit)

Definition at line 438 of file ProtoBotCommander.cpp.

439{
440
441}

◆ onUnitShow()

void ProtoBotCommander::onUnitShow ( BWAPI::Unit unit)

Definition at line 428 of file ProtoBotCommander.cpp.

429{
430 buildManager.onUnitDiscover(unit);
431}

◆ queryThreatAt()

ThreatQueryResult ProtoBotCommander::queryThreatAt ( const BWAPI::Position & pos) const

Definition at line 1015 of file ProtoBotCommander.cpp.

1016{
1017 return InformationManager::Instance().queryThreatAt(pos);
1018}

◆ removeApprovedRequests()

void ProtoBotCommander::removeApprovedRequests ( )

Definition at line 443 of file ProtoBotCommander.cpp.

444{
445 for (std::vector<ResourceRequest>::iterator it = resourceRequests.begin(); it != resourceRequests.end();)
446 {
447 if (it->state == ResourceRequest::State::Accepted_Completed || (it->attempts == MAX_ATTEMPTS && it->fromBuildOrder == false))
448 {
449 const ResourceRequest::Type request_type = it->type;
450 //int mineralCost = -1;
451 //int gasCost = -1;
452 //std::string bwapiType_string;
453 //std::string type_string;
454 //std::string frame_string = (it->frameToStartBuilding == -1 ? "N\\A" : std::to_string(it->frameToStartBuilding));
455 //double seconds = double(it->frameRequestApproved - it->frameRequestCreated) / 24.0;
456
457 switch (request_type)
458 {
459 case ResourceRequest::Unit:
460 /*type_string = "Unit";
461 mineralCost = it->unit.mineralPrice();
462 gasCost = it->unit.gasPrice();
463 bwapiType_string = it->unit.toString();
464
465 std::cout << "Request for " << type_string << " (" << bwapiType_string << ") "
466 << "\nFrame Request Created = " << it->frameRequestCreated
467 << "\nFrame Request Approved = " << it->frameRequestApproved
468 << "\nFrame Request Serviced = " << it->frameRequestServiced
469 << "\nFrame Request Removed = "
470 << BWAPI::Broodwar->getFrameCount() << "\nTotal Frames to Complete = "
471 << (it->frameRequestApproved - it->frameRequestCreated) << "\n";*/
472 break;
473 case ResourceRequest::Building:
474 /*type_string = "Building";
475 mineralCost = it->unit.mineralPrice();
476 gasCost = it->unit.gasPrice();
477 bwapiType_string = it->unit.toString();*/
478 break;
479 case ResourceRequest::Upgrade:
480 /*type_string = "Upgrade";
481 mineralCost = it->upgrade.mineralPrice();
482 gasCost = it->upgrade.gasPrice();
483 bwapiType_string = it->upgrade.toString();*/
484
485 switch (it->upgrade)
486 {
487 case BWAPI::UpgradeTypes::Singularity_Charge:
488 if (requestCounter.singularity_requests > 0)
489 --requestCounter.singularity_requests;
490 break;
491 case BWAPI::UpgradeTypes::Protoss_Ground_Weapons:
492 if (requestCounter.groundWeapons_requests > 0)
493 --requestCounter.groundWeapons_requests;
494 break;
495 case BWAPI::UpgradeTypes::Protoss_Ground_Armor:
496 if (requestCounter.groundArmor_requests > 0)
497 --requestCounter.groundArmor_requests;
498 break;
499 case BWAPI::UpgradeTypes::Protoss_Plasma_Shields:
500 if (requestCounter.plasmaShields_requests > 0)
501 --requestCounter.plasmaShields_requests;
502 break;
503 case BWAPI::UpgradeTypes::Leg_Enhancements:
504 if (requestCounter.legEnhancements_requests > 0)
505 --requestCounter.legEnhancements_requests;
506 break;
507 }
508
509 break;
510 case ResourceRequest::Tech:
511 /*type_string = "Tech";
512 mineralCost = it->tech.mineralPrice();
513 gasCost = it->tech.gasPrice();
514 bwapiType_string = it->tech.toString();*/
515 break;
516 }
517
518 it = resourceRequests.erase(it);
519 }
520 else
521 {
522 it++;
523 }
524 }
525}

◆ requestBuilding()

void ProtoBotCommander::requestBuilding ( BWAPI::UnitType building,
bool fromBuildOrder = false,
bool isWall = false,
bool isRampPlacement = false,
BWAPI::Position nexusPosition = BWAPI::Positions::Invalid,
const BWEM::Base * baseLocation = nullptr )

Definition at line 527 of file ProtoBotCommander.cpp.

528{
529 ResourceRequest request;
530 request.type = ResourceRequest::Type::Building;
531 request.unit = building;
532 request.fromBuildOrder = fromBuildOrder;
533 request.frameRequestCreated = BWAPI::Broodwar->getFrameCount();
534 request.isWall = isWall;
535 request.isRampPlacement = isRampPlacement;
536 request.nexusPositionRef = nexusPosition;
537 request.base = baseLocation;
538 request.requestNumber = ++requestCount;
539
540
541 switch (building)
542 {
543 case BWAPI::UnitTypes::Protoss_Pylon:
544 requestCounter.pylons_requests++;
545 break;
546 case BWAPI::UnitTypes::Protoss_Gateway:
547 requestCounter.gateway_requests++;
548 break;
549 case BWAPI::UnitTypes::Protoss_Nexus:
550 requestCounter.nexus_requests++;
551 break;
552 case BWAPI::UnitTypes::Protoss_Forge:
553 requestCounter.forge_requests++;
554 break;
555 case BWAPI::UnitTypes::Protoss_Cybernetics_Core:
556 requestCounter.cybernetics_requests++;
557 break;
558 case BWAPI::UnitTypes::Protoss_Robotics_Facility:
559 requestCounter.robotics_requests++;
560 break;
561 case BWAPI::UnitTypes::Protoss_Observatory:
562 requestCounter.observatory_requests++;
563 break;
564 case BWAPI::UnitTypes::Protoss_Citadel_of_Adun:
565 requestCounter.citadel_requests++;
566 break;
567 case BWAPI::UnitTypes::Protoss_Templar_Archives:
568 requestCounter.templarArchives_requests++;
569 break;
570 default:
571 break;
572 }
573
574 resourceRequests.push_back(request);
575}

◆ requestCheese()

void ProtoBotCommander::requestCheese ( BWAPI::UnitType building,
BWAPI::Unit unit )

Definition at line 864 of file ProtoBotCommander.cpp.

865{
866 ResourceRequest request;
867 request.type = ResourceRequest::Type::Building;
868 request.unit = building;
869 request.scoutToPlaceBuilding = unit;
870 request.isCheese = true;
871 request.fromBuildOrder = false;
872
873 resourceRequests.push_back(request);
874}

◆ requestedBuilding()

bool ProtoBotCommander::requestedBuilding ( BWAPI::UnitType building,
BWAPI::Position nexusPosition = BWAPI::Positions::Invalid )

Definition at line 653 of file ProtoBotCommander.cpp.

654{
655 for (const ResourceRequest& request : resourceRequests)
656 {
657 if (building == request.unit && request.nexusPositionRef == nexusPosition && !request.isCheese)
658 {
659 //if (request.nexusPositionRef != BWAPI::Positions::Invalid) std::cout << "Nexus at " << request.nexusPositionRef << " already has assimilator requested\n";
660
661 return true;
662 }
663 }
664 return false;
665}

◆ requestUnit()

void ProtoBotCommander::requestUnit ( BWAPI::UnitType unit,
BWAPI::Unit buildingToTrain,
bool fromBuildOrder = false )

Definition at line 577 of file ProtoBotCommander.cpp.

578{
579 ResourceRequest request;
580 request.type = ResourceRequest::Type::Unit;
581 request.unit = unit;
582 request.frameRequestCreated = BWAPI::Broodwar->getFrameCount();
583 request.requestedBuilding = buildingToTrain;
584 request.fromBuildOrder = fromBuildOrder;
585 request.requestNumber = ++requestCount;
586
587 switch (unit)
588 {
589 case BWAPI::UnitTypes::Protoss_Probe:
590 requestCounter.worker_requests++;
591 break;
592 case BWAPI::UnitTypes::Protoss_Zealot:
593 requestCounter.zealots_requests++;
594 break;
595 case BWAPI::UnitTypes::Protoss_Dragoon:
596 requestCounter.dragoons_requests++;
597 break;
598 case BWAPI::UnitTypes::Protoss_Observer:
599 requestCounter.observers_requests++;
600 break;
601 case BWAPI::UnitTypes::Protoss_Dark_Templar:
602 requestCounter.dark_templars_requests++;
603 break;
604 }
605
606 resourceRequests.push_back(request);
607}

◆ requestUpgrade()

void ProtoBotCommander::requestUpgrade ( BWAPI::Unit unit,
BWAPI::UpgradeType upgrade,
bool fromBuildOrder = false )

Definition at line 609 of file ProtoBotCommander.cpp.

610{
611 ResourceRequest request;
612 request.type = ResourceRequest::Type::Upgrade;
613 request.frameRequestCreated = BWAPI::Broodwar->getFrameCount();
614 request.upgrade = upgrade;
615 request.requestedBuilding = unit;
616 request.fromBuildOrder = fromBuildOrder;
617 request.requestNumber = ++requestCount;
618
619 switch (request.upgrade)
620 {
621 case BWAPI::UpgradeTypes::Singularity_Charge:
622 requestCounter.singularity_requests++;
623 break;
624 case BWAPI::UpgradeTypes::Protoss_Ground_Weapons:
625 requestCounter.groundWeapons_requests++;
626 break;
627 case BWAPI::UpgradeTypes::Protoss_Ground_Armor:
628 requestCounter.groundArmor_requests++;
629 break;
630 case BWAPI::UpgradeTypes::Protoss_Plasma_Shields:
631 requestCounter.plasmaShields_requests++;
632 break;
633 case BWAPI::UpgradeTypes::Leg_Enhancements:
634 requestCounter.legEnhancements_requests++;
635 break;
636 }
637
638 resourceRequests.push_back(request);
639}

◆ shouldGasSteal()

bool ProtoBotCommander::shouldGasSteal ( )

Definition at line 1032 of file ProtoBotCommander.cpp.

1033{
1034 bool const enable = strategyManager.shouldGasSteal();
1035
1036 return enable;
1037}

◆ upgradeAlreadyRequested()

bool ProtoBotCommander::upgradeAlreadyRequested ( BWAPI::Unit building)

Definition at line 667 of file ProtoBotCommander.cpp.

668{
669 for (const ResourceRequest& request : resourceRequests)
670 {
671 if (request.requestedBuilding != nullptr)
672 {
673 if (building->getID() == request.requestedBuilding->getID()) return true;
674 }
675 }
676 return false;
677}

Member Data Documentation

◆ buildManager

BuildManager ProtoBotCommander::buildManager

Definition at line 141 of file ProtoBotCommander.h.

◆ combatManager

CombatManager ProtoBotCommander::combatManager

Definition at line 142 of file ProtoBotCommander.h.

◆ drawBWEBDebug

bool ProtoBotCommander::drawBWEBDebug = false

Definition at line 148 of file ProtoBotCommander.h.

◆ drawToolsDebug

bool ProtoBotCommander::drawToolsDebug = false

Definition at line 149 of file ProtoBotCommander.h.

◆ drawUnitDebug

bool ProtoBotCommander::drawUnitDebug = false

Definition at line 147 of file ProtoBotCommander.h.

◆ economyManager

EconomyManager ProtoBotCommander::economyManager

Definition at line 139 of file ProtoBotCommander.h.

◆ enemy_

EnemyLocations ProtoBotCommander::enemy_
private

Definition at line 222 of file ProtoBotCommander.h.

◆ m_mapTools

MapTools ProtoBotCommander::m_mapTools

Definition at line 137 of file ProtoBotCommander.h.

◆ requestCount

int ProtoBotCommander::requestCount = 0

Definition at line 151 of file ProtoBotCommander.h.

◆ requestCounter

ProtoBotRequestCounter ProtoBotCommander::requestCounter

Definition at line 144 of file ProtoBotCommander.h.

◆ resourceRequests

std::vector<ResourceRequest> ProtoBotCommander::resourceRequests

Definition at line 153 of file ProtoBotCommander.h.

◆ scoutingManager

ScoutingManager ProtoBotCommander::scoutingManager

Definition at line 140 of file ProtoBotCommander.h.

◆ strategyManager

StrategyManager ProtoBotCommander::strategyManager

Definition at line 143 of file ProtoBotCommander.h.

◆ timerManager

TimerManager ProtoBotCommander::timerManager

Definition at line 138 of file ProtoBotCommander.h.


The documentation for this class was generated from the following files: