|
BWAPI
|
#include <Skynet.h>


Public Member Functions | |
| Skynet () | |
| virtual void | onStart () |
| virtual void | onEnd (bool isWinner) |
| virtual void | onFrame () |
| virtual void | onSendText (std::string text) |
| virtual void | onPlayerLeft (Player player) |
Private Attributes | |
| bool | mOnBegin |
| int | mLeavingGame |
| bool | mSaidGG |
| Skynet::Skynet | ( | ) |
Definition at line 36 of file Skynet.cpp.
: mOnBegin(false) , mLeavingGame(0) , mSaidGG(false) { }
| void Skynet::onEnd | ( | bool | isWinner | ) | [virtual] |
BWAPI calls this at the end of the match. isWinner will be true if the AIModule won the game. If the game is a replay, isWinner will always be false.
Reimplemented from BWAPI::AIModule.
Definition at line 54 of file Skynet.cpp.
{
}
| void Skynet::onFrame | ( | ) | [virtual] |
BWAPI calls this on every logical frame in the game.
Reimplemented from BWAPI::AIModule.
Definition at line 58 of file Skynet.cpp.
References BWAPI::Broodwar, BWAPI::Game::getFrameCount(), Singleton< T >::Instance(), BWAPI::Game::leaveGame(), mLeavingGame, mOnBegin, mSaidGG, BWAPI::Game::sendText(), BWAPI::Event::type, BWAPI::Event::unit, BWAPI::EventType::UnitDestroy, and BWAPI::EventType::UnitDiscover.
{
for each(BWAPI::Event BWAPIEvent in BWAPI::Broodwar->getEvents())
{
if(BWAPIEvent.type == BWAPI::EventType::UnitDiscover)
UnitTracker::Instance().onUnitDiscover(BWAPIEvent.unit);
}
for each(BWAPI::Event BWAPIEvent in BWAPI::Broodwar->getEvents())
{
if(BWAPIEvent.type == BWAPI::EventType::UnitDestroy)
UnitTracker::Instance().onUnitDestroy(BWAPIEvent.unit);
}
if(!mOnBegin)
{
mOnBegin = true;
WallTracker::Instance().onBegin();
PlayerTracker::Instance().onBegin();
TerrainAnaysis::Instance().analyseBasesAndTerrain();
BorderTracker::Instance().onBegin();
UnitTracker::Instance().pumpUnitEvents();
ScoutManager::Instance().onBegin();
MacroManager::Instance().onBegin();
BuildOrderManager::Instance().onBegin();
BlockedPathManager::Instance().onBegin();
}
UnitTracker::Instance().update();
AOEThreatTracker::Instance().update();
BlockedPathManager::Instance().update();
PylonPowerTracker::Instance().update();
UnitInformation::Instance().update();
BorderTracker::Instance().update();
PlayerTracker::Instance().update();
BaseTracker::Instance().update();
BuildingPlacer::Instance().update();
ResourceManager::Instance().update();
SupplyManager::Instance().update();
MacroManager::Instance().update();
ExpansionManager::Instance().update();
LatencyTracker::Instance().update();
GameProgressDetection::Instance().update();
BuildOrderManager::Instance().update();
ScoutManager::Instance().update();
SquadManager::Instance().update();
TaskManager::Instance().update();
DrawBuffer::Instance().update();
if(GameProgressDetection::Instance().shouldGG())
{
if(mLeavingGame == 0)
mLeavingGame = BWAPI::Broodwar->getFrameCount();
}
else
mLeavingGame = 0;
if(mLeavingGame != 0)
{
if(BWAPI::Broodwar->getFrameCount() - mLeavingGame > 24 && !mSaidGG)
{
mSaidGG = true;
BWAPI::Broodwar->sendText("gg");
}
else if(BWAPI::Broodwar->getFrameCount() - mLeavingGame > 80)
BWAPI::Broodwar->leaveGame();
}
}

| void Skynet::onPlayerLeft | ( | Player | player | ) | [virtual] |
Definition at line 138 of file Skynet.cpp.
References Singleton< T >::Instance().
{
PlayerTracker::Instance().onPlayerLeft(player);
}
| void Skynet::onSendText | ( | std::string | text | ) | [virtual] |
If Flag::UserInput is enabled, BWAPI will call this each time a user enters a message into the chat.
Reimplemented from BWAPI::AIModule.
Definition at line 133 of file Skynet.cpp.
References BWAPI::Broodwar, and BWAPI::Game::sendText().
{
BWAPI::Broodwar->sendText(text.c_str());
}

| void Skynet::onStart | ( | ) | [virtual] |
BWAPI calls this at the start of a match. Typically an AI will execute set up code in this method (initialize data structures, load build orders, etc).
Reimplemented from BWAPI::AIModule.
Definition at line 43 of file Skynet.cpp.
References BWAPI::Broodwar, BWAPI::Races::getRace(), BWAPI::Races::Protoss, BWAPI::Game::sendText(), BWAPI::Game::setCommandOptimizationLevel(), and BWAPI::Game::setLatCom().
{
BWAPI::Broodwar->sendText("Skynet 2.0 Operational");
BWAPI::Broodwar->setLatCom(false);
BWAPI::Broodwar->setCommandOptimizationLevel(1);
if(BWAPI::Broodwar->self()->getRace() != BWAPI::Races::Protoss)
BWAPI::Broodwar->sendText("Skynet is a Protoss only bot");
}

int Skynet::mLeavingGame [private] |
bool Skynet::mOnBegin [private] |
bool Skynet::mSaidGG [private] |
1.7.6.1