\hypertarget{classExpansionManagerClass}{\section{\-Expansion\-Manager\-Class \-Class \-Reference}
\label{classExpansionManagerClass}\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}}
}


{\ttfamily \#include $<$\-Expansion\-Manager.\-h$>$}

\subsection*{\-Public \-Member \-Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{classExpansionManagerClass_a2e7a0ec91c3867b50d982b22012dc6d9}{\-Expansion\-Manager\-Class} ()
\item 
void \hyperlink{classExpansionManagerClass_af824e3d30c9f978d6277338e429a62fd}{update} ()
\end{DoxyCompactItemize}
\subsection*{\-Private \-Member \-Functions}
\begin{DoxyCompactItemize}
\item 
void \hyperlink{classExpansionManagerClass_a84c671245cfaca198dbe7150a1d0c65e}{update\-Refineries} ()
\item 
void \hyperlink{classExpansionManagerClass_aea3c7d4a5151b564c3fa206f35d9038f}{update\-Defense} ()
\item 
void \hyperlink{classExpansionManagerClass_ac99a7b36abd73702dc35b3fff97d50d6}{update\-Expands} ()
\end{DoxyCompactItemize}
\subsection*{\-Private \-Attributes}
\begin{DoxyCompactItemize}
\item 
std\-::list$<$ \hyperlink{Requirement_8h_a10d9e68ef4957f6a76bc93eb32bf2670}{\-Task\-Pointer} $>$ \hyperlink{classExpansionManagerClass_ad5a3d546d4b30dfa33c8fd83772310d3}{m\-Refinery\-Tasks}
\item 
\hyperlink{Requirement_8h_a10d9e68ef4957f6a76bc93eb32bf2670}{\-Task\-Pointer} \hyperlink{classExpansionManagerClass_af753c70693b8969599d78519c2c6071b}{m\-Pylon}
\item 
std\-::list$<$ \hyperlink{Requirement_8h_a10d9e68ef4957f6a76bc93eb32bf2670}{\-Task\-Pointer} $>$ \hyperlink{classExpansionManagerClass_a6614265080fa162caba7b35ecf2bb3b9}{m\-Defense\-Tasks}
\item 
std\-::list$<$ \hyperlink{Requirement_8h_a10d9e68ef4957f6a76bc93eb32bf2670}{\-Task\-Pointer} $>$ \hyperlink{classExpansionManagerClass_a38a05136ba7c57f4a0f17d477933898a}{m\-Expand\-Tasks}
\end{DoxyCompactItemize}


\subsection{\-Detailed \-Description}


\-Definition at line 8 of file \-Expansion\-Manager.\-h.



\subsection{\-Constructor \& \-Destructor \-Documentation}
\hypertarget{classExpansionManagerClass_a2e7a0ec91c3867b50d982b22012dc6d9}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}}
\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{\-Expansion\-Manager\-Class}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Expansion\-Manager\-Class\-::\-Expansion\-Manager\-Class} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classExpansionManagerClass_a2e7a0ec91c3867b50d982b22012dc6d9}


\-Definition at line 12 of file \-Expansion\-Manager.\-cpp.


\begin{DoxyCode}
{
}
\end{DoxyCode}


\subsection{\-Member \-Function \-Documentation}
\hypertarget{classExpansionManagerClass_af824e3d30c9f978d6277338e429a62fd}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!update@{update}}
\index{update@{update}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{update}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Expansion\-Manager\-Class\-::update} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{classExpansionManagerClass_af824e3d30c9f978d6277338e429a62fd}


\-Definition at line 16 of file \-Expansion\-Manager.\-cpp.



\-References \-Order\-Def\-::\-Expansion\-Manager, \-B\-W\-A\-P\-I\-::\-Orders\-::get\-Order(), \-Singleton$<$ T $>$\-::\-Instance(), \-Order\-Def\-::\-Refinery\-Manager, update\-Defense(), update\-Expands(), and update\-Refineries().


\begin{DoxyCode}
{
        if(BuildOrderManager::Instance().getOrder(Order::RefineryManager))
                updateRefineries();

        if(BuildOrderManager::Instance().getOrder(Order::ExpansionManager))
        {
                updateDefense();
                updateExpands();
        }
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_af824e3d30c9f978d6277338e429a62fd_cgraph}
\end{center}
\end{figure}


\hypertarget{classExpansionManagerClass_aea3c7d4a5151b564c3fa206f35d9038f}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!update\-Defense@{update\-Defense}}
\index{update\-Defense@{update\-Defense}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{update\-Defense}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Expansion\-Manager\-Class\-::update\-Defense} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_aea3c7d4a5151b564c3fa206f35d9038f}


\-Definition at line 62 of file \-Expansion\-Manager.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Broodwar, \-Task\-Type\-Def\-::\-Defense, \-B\-W\-A\-P\-I\-::\-Player\-::get\-Race(), \-B\-W\-A\-P\-I\-::\-Races\-::get\-Race(), \-Singleton$<$ T $>$\-::\-Instance(), \-L\-O\-G\-M\-E\-S\-S\-A\-G\-E, m\-Defense\-Tasks, m\-Pylon, \-B\-W\-A\-P\-I\-::\-Races\-::\-Protoss, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Photon\-\_\-\-Cannon, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Pylon, \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::requires\-Psi(), \-B\-W\-A\-P\-I\-::\-Game\-::self(), \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Missile\-\_\-\-Turret, and \-B\-W\-A\-P\-I\-::\-Races\-::\-Zerg.



\-Referenced by update().


\begin{DoxyCode}
{
        if(BWAPI::Broodwar->self()->getRace() == BWAPI::Races::Zerg)
                return;

        BWAPI::UnitType defenseType = BWAPI::Broodwar->self()->getRace() == 
      BWAPI::Races::Protoss ? BWAPI::UnitTypes::Protoss_Photon_Cannon : 
      BWAPI::UnitTypes::Terran_Missile_Turret;

        if(!MacroManager::Instance().hasRequirements(defenseType))
                return;

        std::set<Base> myBases = BaseTracker::Instance().getActiveBases(true);
        if(myBases.size() >= 2)
        {
                int defensesNeeded = 0;
                int neededPerBase = PlayerTracker::Instance().isEnemyRace(
      BWAPI::Races::Zerg) ? 4 : 2;

                for each(Base base in myBases)
                {
                        if(base->getMinerals().empty())
                                continue;

                        bool hasPylon = defenseType.requiresPsi() ? false : 
      true;
                        int thisCount = 0;
                        for each(Unit building in base->getBuildings())
                        {
                                if(building->getType() == defenseType)
                                        ++thisCount;

                                if(building->getType() == 
      BWAPI::UnitTypes::Protoss_Pylon)
                                {
                                        if(building->isCompleted())
                                                hasPylon = true;
                                }
                        }

                        if(hasPylon)
                        {
                                defensesNeeded += neededPerBase;
                                defensesNeeded -= std::min(thisCount, 
      neededPerBase);
                        }
                        else if(BWAPI::Broodwar->self()->supplyTotal() >= 380 
      && (!mPylon || mPylon->hasEnded()))
                                mPylon = TaskManager::Instance().build(
      BWAPI::UnitTypes::Protoss_Pylon, TaskType::Defense);
                }

                for(std::list<TaskPointer>::iterator it = mDefenseTasks.begin()
      ; it != mDefenseTasks.end();)
                {
                        if((*it)->hasEnded())
                                mDefenseTasks.erase(it++);
                        else
                        {
                                if(!(*it)->inProgress())
                                        --defensesNeeded;
                                ++it;
                        }
                }

                if(defensesNeeded > 0)
                {
                        for(int i = 0; i < defensesNeeded; ++i)
                        {
                                LOGMESSAGE(String_Builder() << "Built Defense."
      );
                                mDefenseTasks.push_front(TaskManager::Instance(
      ).build(defenseType, TaskType::Defense));
                        }
                }
                else if(defensesNeeded < 0)
                {
                        for(int i = 0; i < defensesNeeded; ++i)
                        {
                                std::list<TaskPointer>::iterator begin = 
      mDefenseTasks.begin();
                                LOGMESSAGE(String_Builder() << "Cancelled
       Defense.");
                                (*begin)->cancel();
                                mDefenseTasks.erase(begin);
                        }
                }
        }
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_aea3c7d4a5151b564c3fa206f35d9038f_cgraph}
\end{center}
\end{figure}




\-Here is the caller graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_aea3c7d4a5151b564c3fa206f35d9038f_icgraph}
\end{center}
\end{figure}


\hypertarget{classExpansionManagerClass_ac99a7b36abd73702dc35b3fff97d50d6}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!update\-Expands@{update\-Expands}}
\index{update\-Expands@{update\-Expands}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{update\-Expands}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Expansion\-Manager\-Class\-::update\-Expands} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_ac99a7b36abd73702dc35b3fff97d50d6}


\-Definition at line 139 of file \-Expansion\-Manager.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Broodwar, \-Task\-Type\-Def\-::\-Expansion, \-Building\-Location\-Def\-::\-Expansion, \-B\-W\-A\-P\-I\-::\-Races\-::get\-Race(), \-Singleton$<$ T $>$\-::\-Instance(), \-L\-O\-G\-M\-E\-S\-S\-A\-G\-E, and m\-Expand\-Tasks.



\-Referenced by update().


\begin{DoxyCode}
{
        bool unstartedTasks = false;

        for(std::list<TaskPointer>::iterator it = mExpandTasks.begin(); it != 
      mExpandTasks.end();)
        {
                if((*it)->hasEnded())
                        mExpandTasks.erase(it++);
                else
                {
                        if(!(*it)->inProgress())
                                unstartedTasks = true;
                        ++it;
                }
        }

        if(ResourceManager::Instance().isSaturated() && !unstartedTasks)
        {
                LOGMESSAGE(String_Builder() << "Expanded because im saturated."
      );
                mExpandTasks.push_front(TaskManager::Instance().build(
      BWAPI::Broodwar->self()->getRace().getCenter(), TaskType::Expansion, 
      BuildingLocation::Expansion));
        }
}\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_ac99a7b36abd73702dc35b3fff97d50d6_cgraph}
\end{center}
\end{figure}




\-Here is the caller graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_ac99a7b36abd73702dc35b3fff97d50d6_icgraph}
\end{center}
\end{figure}


\hypertarget{classExpansionManagerClass_a84c671245cfaca198dbe7150a1d0c65e}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!update\-Refineries@{update\-Refineries}}
\index{update\-Refineries@{update\-Refineries}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{update\-Refineries}]{\setlength{\rightskip}{0pt plus 5cm}void {\bf \-Expansion\-Manager\-Class\-::update\-Refineries} (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_a84c671245cfaca198dbe7150a1d0c65e}


\-Definition at line 28 of file \-Expansion\-Manager.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Broodwar, \-B\-W\-A\-P\-I\-::\-Game\-::get\-Frame\-Count(), \-B\-W\-A\-P\-I\-::\-Player\-::get\-Race(), \-B\-W\-A\-P\-I\-::\-Races\-::get\-Race(), \-B\-W\-A\-P\-I\-::\-Race\-::get\-Refinery(), \-Singleton$<$ T $>$\-::\-Instance(), m\-Refinery\-Tasks, \-Task\-Type\-Def\-::\-Refinery\-Manager, and \-B\-W\-A\-P\-I\-::\-Game\-::self().



\-Referenced by update().


\begin{DoxyCode}
{
        int refNeeded = 0;
        for each(Base base in BaseTracker::Instance().getActiveBases(true))
        {
                if(base->getActivateTime() < unsigned int(BWAPI::Broodwar->
      getFrameCount() + BWAPI::Broodwar->self()->getRace().getRefinery().buildTime()))
                        refNeeded += base->getGeysers().size();
        }

        for(std::list<TaskPointer>::iterator it = mRefineryTasks.begin(); it !=
       mRefineryTasks.end();)
        {
                if((*it)->hasEnded())
                        mRefineryTasks.erase(it++);
                else
                {
                        if(!(*it)->inProgress())
                                --refNeeded;
                        ++it;
                }
        }

        if(ResourceManager::Instance().requiresRefineries() && refNeeded > 0 &&
       BWAPI::Broodwar->getFrameCount() % 50 == 0)
                mRefineryTasks.push_front(TaskManager::Instance().build(
      BWAPI::Broodwar->self()->getRace().getRefinery(), TaskType::RefineryManager));
        else if(refNeeded < 0)
        {
                for(int i = 0; i < refNeeded; ++i)
                {
                        std::list<TaskPointer>::iterator begin = mRefineryTasks
      .begin();
                        (*begin)->cancel();
                        mRefineryTasks.erase(begin);
                }
        }
}
\end{DoxyCode}


\-Here is the call graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_a84c671245cfaca198dbe7150a1d0c65e_cgraph}
\end{center}
\end{figure}




\-Here is the caller graph for this function\-:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{classExpansionManagerClass_a84c671245cfaca198dbe7150a1d0c65e_icgraph}
\end{center}
\end{figure}




\subsection{\-Member \-Data \-Documentation}
\hypertarget{classExpansionManagerClass_a6614265080fa162caba7b35ecf2bb3b9}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!m\-Defense\-Tasks@{m\-Defense\-Tasks}}
\index{m\-Defense\-Tasks@{m\-Defense\-Tasks}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{m\-Defense\-Tasks}]{\setlength{\rightskip}{0pt plus 5cm}std\-::list$<${\bf \-Task\-Pointer}$>$ {\bf \-Expansion\-Manager\-Class\-::m\-Defense\-Tasks}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_a6614265080fa162caba7b35ecf2bb3b9}


\-Definition at line 20 of file \-Expansion\-Manager.\-h.



\-Referenced by update\-Defense().

\hypertarget{classExpansionManagerClass_a38a05136ba7c57f4a0f17d477933898a}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!m\-Expand\-Tasks@{m\-Expand\-Tasks}}
\index{m\-Expand\-Tasks@{m\-Expand\-Tasks}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{m\-Expand\-Tasks}]{\setlength{\rightskip}{0pt plus 5cm}std\-::list$<${\bf \-Task\-Pointer}$>$ {\bf \-Expansion\-Manager\-Class\-::m\-Expand\-Tasks}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_a38a05136ba7c57f4a0f17d477933898a}


\-Definition at line 23 of file \-Expansion\-Manager.\-h.



\-Referenced by update\-Expands().

\hypertarget{classExpansionManagerClass_af753c70693b8969599d78519c2c6071b}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!m\-Pylon@{m\-Pylon}}
\index{m\-Pylon@{m\-Pylon}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{m\-Pylon}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Task\-Pointer} {\bf \-Expansion\-Manager\-Class\-::m\-Pylon}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_af753c70693b8969599d78519c2c6071b}


\-Definition at line 19 of file \-Expansion\-Manager.\-h.



\-Referenced by update\-Defense().

\hypertarget{classExpansionManagerClass_ad5a3d546d4b30dfa33c8fd83772310d3}{\index{\-Expansion\-Manager\-Class@{\-Expansion\-Manager\-Class}!m\-Refinery\-Tasks@{m\-Refinery\-Tasks}}
\index{m\-Refinery\-Tasks@{m\-Refinery\-Tasks}!ExpansionManagerClass@{\-Expansion\-Manager\-Class}}
\subsubsection[{m\-Refinery\-Tasks}]{\setlength{\rightskip}{0pt plus 5cm}std\-::list$<${\bf \-Task\-Pointer}$>$ {\bf \-Expansion\-Manager\-Class\-::m\-Refinery\-Tasks}\hspace{0.3cm}{\ttfamily  \mbox{[}private\mbox{]}}}}\label{classExpansionManagerClass_ad5a3d546d4b30dfa33c8fd83772310d3}


\-Definition at line 16 of file \-Expansion\-Manager.\-h.



\-Referenced by update\-Refineries().



\-The documentation for this class was generated from the following files\-:\begin{DoxyCompactItemize}
\item 
\-Skynet/\-Skynet/\hyperlink{ExpansionManager_8h}{\-Expansion\-Manager.\-h}\item 
\-Skynet/\-Skynet/\hyperlink{ExpansionManager_8cpp}{\-Expansion\-Manager.\-cpp}\end{DoxyCompactItemize}
