\hypertarget{namespaceUnitHelper}{\section{\-Unit\-Helper \-Namespace \-Reference}
\label{namespaceUnitHelper}\index{\-Unit\-Helper@{\-Unit\-Helper}}
}
\subsection*{\-Functions}
\begin{DoxyCompactItemize}
\item 
bool \hyperlink{namespaceUnitHelper_a06f1422c822b556d6faf84d7f321ff24}{unit\-Produces\-Ground} (\hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type)
\item 
std\-::vector$<$ \hyperlink{classUnitGroup}{\-Unit\-Group} $>$ \hyperlink{namespaceUnitHelper_a5e8534a5831476c0e82ed2d428b18541}{get\-Clusters} (const \hyperlink{classUnitGroup}{\-Unit\-Group} \&units, int distance, int min\-Size)
\item 
bool \hyperlink{namespaceUnitHelper_a3d83858114b239472abe19e818d00d79}{has\-Addon} (\hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type)
\item 
bool \hyperlink{namespaceUnitHelper_a9f219094ea8f9dd6aef7705df253379e}{is\-Static\-Defense} (\hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type)
\item 
bool \hyperlink{namespaceUnitHelper_af3f78f889198bce87dfff4f421b7b965}{is\-Army\-Unit} (\hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type)
\item 
\hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \hyperlink{namespaceUnitHelper_a2530801f9cfea9bdae1c76c9ed8de083}{tile\-To\-Position} (\hyperlink{Interface_8h_ad2186bdc15b990e538451931b3e11c67}{\-Tile\-Position} tile, \hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type)
\item 
int \hyperlink{namespaceUnitHelper_a4b4ab68be46edc52a999aff727473f03}{get\-Distance} (const \hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \&pos1, const \hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type1, const \hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \&pos2, const \hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type2)
\item 
int \hyperlink{namespaceUnitHelper_a624afc959c47b0889fb0e1a32d6eaefc}{get\-Distance} (const \hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \&pos1, const \hyperlink{classBWAPI_1_1UnitType}{\-B\-W\-A\-P\-I\-::\-Unit\-Type} type1, const \hyperlink{Interface_8h_a7ae5d695cf6b7c013c5ad30d124278e0}{\-Position} \&pos2)
\end{DoxyCompactItemize}


\subsection{\-Function \-Documentation}
\hypertarget{namespaceUnitHelper_a5e8534a5831476c0e82ed2d428b18541}{\index{\-Unit\-Helper@{\-Unit\-Helper}!get\-Clusters@{get\-Clusters}}
\index{get\-Clusters@{get\-Clusters}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{get\-Clusters}]{\setlength{\rightskip}{0pt plus 5cm}std\-::vector$<$ {\bf \-Unit\-Group} $>$ {\bf \-Unit\-Helper\-::get\-Clusters} (
\begin{DoxyParamCaption}
\item[{const {\bf \-Unit\-Group} \&}]{units, }
\item[{int}]{distance, }
\item[{int}]{min\-Size}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a5e8534a5831476c0e82ed2d428b18541}


\-Definition at line 35 of file \-Unit\-Helper.\-cpp.



\-References \-Unit\-Group\-::insert().



\-Referenced by \-Terrain\-Anaysis\-Class\-::create\-Bases(), and \-Player\-Tracker\-Class\-::update().


\begin{DoxyCode}
{
        std::vector<UnitGroup> clusters;

        for each(Unit unit in units)
        {
                std::vector<size_t> clustersInRange;
                for(size_t i = 0; i < clusters.size(); ++i)
                {
                        for each(Unit clusterUnit in clusters[i])
                        {
                                if(unit->getPosition().getApproxDistance(
      clusterUnit->getPosition()) <= distance)
                                {
                                        clustersInRange.push_back(i);
                                        break;
                                }
                        }
                }

                if(clustersInRange.empty())
                {
                        UnitGroup newCluster;
                        newCluster.insert(unit);
                        clusters.push_back(newCluster);
                }
                else
                {
                        clusters[clustersInRange[0]].insert(unit);

                        for(size_t i = 1; i < clustersInRange.size(); ++i)
                        {
                                for each(Unit clusterUnit in clusters[
      clustersInRange[i]])
                                {
                                        clusters[clustersInRange[0]].insert(
      clusterUnit);
                                }
                                clusters[clustersInRange[i]].clear();
                        }
                }
        }

        clusters.erase(std::remove_if(clusters.begin(), clusters.end(), 
      ClusterCompare(minSize)), clusters.end());

        return clusters;
}
\end{DoxyCode}


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




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


\hypertarget{namespaceUnitHelper_a4b4ab68be46edc52a999aff727473f03}{\index{\-Unit\-Helper@{\-Unit\-Helper}!get\-Distance@{get\-Distance}}
\index{get\-Distance@{get\-Distance}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{get\-Distance}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf \-Unit\-Helper\-::get\-Distance} (
\begin{DoxyParamCaption}
\item[{const {\bf \-Position} \&}]{pos1, }
\item[{const {\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type1, }
\item[{const {\bf \-Position} \&}]{pos2, }
\item[{const {\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type2}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a4b4ab68be46edc52a999aff727473f03}


\-Definition at line 129 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Down(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Left(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Right(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Up(), \-B\-W\-A\-P\-I\-::\-Position\-::get\-Approx\-Distance(), \-B\-W\-A\-P\-I\-::\-Position\-::x(), and \-B\-W\-A\-P\-I\-::\-Position\-::y().


\begin{DoxyCode}
{
        const int uLeft       = pos1.x() - type1.dimensionLeft();
        const int uTop        = pos1.y() - type1.dimensionUp();
        const int uRight      = pos1.x() + type1.dimensionRight() + 1;
        const int uBottom     = pos1.y() + type1.dimensionDown() + 1;

        const int targLeft    = pos2.x() - type2.dimensionLeft();
        const int targTop     = pos2.y() - type2.dimensionUp();
        const int targRight   = pos2.x() + type2.dimensionRight() + 1;
        const int targBottom  = pos2.y() + type2.dimensionDown() + 1;

        int xDist = uLeft - targRight;
        if(xDist < 0)
        {
                xDist = targLeft - uRight;
                if(xDist < 0)
                        xDist = 0;
        }

        int yDist = uTop - targBottom;
        if(yDist < 0)
        {
                yDist = targTop - uBottom;
                if(yDist < 0)
                        yDist = 0;
        }

        return Position(0, 0).getApproxDistance(Position(xDist, yDist));
}
\end{DoxyCode}


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


\hypertarget{namespaceUnitHelper_a624afc959c47b0889fb0e1a32d6eaefc}{\index{\-Unit\-Helper@{\-Unit\-Helper}!get\-Distance@{get\-Distance}}
\index{get\-Distance@{get\-Distance}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{get\-Distance}]{\setlength{\rightskip}{0pt plus 5cm}int {\bf \-Unit\-Helper\-::get\-Distance} (
\begin{DoxyParamCaption}
\item[{const {\bf \-Position} \&}]{pos1, }
\item[{const {\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type1, }
\item[{const {\bf \-Position} \&}]{pos2}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a624afc959c47b0889fb0e1a32d6eaefc}


\-Definition at line 160 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Down(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Left(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Right(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::dimension\-Up(), \-B\-W\-A\-P\-I\-::\-Position\-::get\-Approx\-Distance(), \-B\-W\-A\-P\-I\-::\-Position\-::x(), and \-B\-W\-A\-P\-I\-::\-Position\-::y().


\begin{DoxyCode}
{
        const int uLeft       = pos1.x() - type1.dimensionLeft();
        const int uTop        = pos1.y() - type1.dimensionUp();
        const int uRight      = pos1.x() + type1.dimensionRight() + 1;
        const int uBottom     = pos1.y() + type1.dimensionDown() + 1;

        int xDist = uLeft - (pos2.x() + 1);
        if(xDist < 0)
        {
                xDist = pos2.x() - uRight;
                if(xDist < 0)
                        xDist = 0;
        }

        int yDist = uTop - (pos2.y() + 1);
        if(yDist < 0)
        {
                yDist = pos2.y() - uBottom;
                if(yDist < 0)
                        yDist = 0;
        }

        return Position(0, 0).getApproxDistance(Position(xDist, yDist));
}\end{DoxyCode}


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


\hypertarget{namespaceUnitHelper_a3d83858114b239472abe19e818d00d79}{\index{\-Unit\-Helper@{\-Unit\-Helper}!has\-Addon@{has\-Addon}}
\index{has\-Addon@{has\-Addon}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{has\-Addon}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Unit\-Helper\-::has\-Addon} (
\begin{DoxyParamCaption}
\item[{{\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a3d83858114b239472abe19e818d00d79}


\-Definition at line 80 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Command\-\_\-\-Center, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Factory, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Science\-\_\-\-Facility, and \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Starport.



\-Referenced by \-Building\-Placer\-Class\-::free(), \-Building\-Placer\-Class\-::is\-Addon\-Builder(), \-Building\-Placer\-Class\-::is\-Location\-Buildable(), and \-Building\-Placer\-Class\-::reserve().


\begin{DoxyCode}
{
        return(type == BWAPI::UnitTypes::Terran_Command_Center ||
                type == BWAPI::UnitTypes::Terran_Factory || 
                type == BWAPI::UnitTypes::Terran_Starport ||
                type == BWAPI::UnitTypes::Terran_Science_Facility);
}
\end{DoxyCode}


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


\hypertarget{namespaceUnitHelper_af3f78f889198bce87dfff4f421b7b965}{\index{\-Unit\-Helper@{\-Unit\-Helper}!is\-Army\-Unit@{is\-Army\-Unit}}
\index{is\-Army\-Unit@{is\-Army\-Unit}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{is\-Army\-Unit}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Unit\-Helper\-::is\-Army\-Unit} (
\begin{DoxyParamCaption}
\item[{{\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_af3f78f889198bce87dfff4f421b7b965}


\-Definition at line 103 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Broodwar, \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::is\-Building(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::is\-Spell(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::is\-Worker(), \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Interceptor, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Observer, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Scarab, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Vulture\-\_\-\-Spider\-\_\-\-Mine, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Egg, and \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Larva.



\-Referenced by \-Unit\-Filter\-::filter(), \-Detector\-Action\-::update(), \-Arbiter\-Action\-::update(), \-Basic\-Unit\-Action\-::update(), and \-Base\-Class\-::update().


\begin{DoxyCode}
{
        if(type.isBuilding())
                return false;
        if(type.isSpell())
                return false;
        if(type.isWorker())
                return false;
        if(type == BWAPI::Broodwar->self()->getRace().getSupplyProvider())
                return false;
        if(type == BWAPI::UnitTypes::Zerg_Egg)
                return false;
        if(type == BWAPI::UnitTypes::Protoss_Interceptor)
                return false;
        if(type == BWAPI::UnitTypes::Terran_Vulture_Spider_Mine)
                return false;
        if(type == BWAPI::UnitTypes::Zerg_Larva)
                return false;
        if(type == BWAPI::UnitTypes::Protoss_Scarab)
                return false;
        if(type == BWAPI::UnitTypes::Protoss_Observer)
                return false;

        return true;
}
\end{DoxyCode}


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




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


\hypertarget{namespaceUnitHelper_a9f219094ea8f9dd6aef7705df253379e}{\index{\-Unit\-Helper@{\-Unit\-Helper}!is\-Static\-Defense@{is\-Static\-Defense}}
\index{is\-Static\-Defense@{is\-Static\-Defense}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{is\-Static\-Defense}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Unit\-Helper\-::is\-Static\-Defense} (
\begin{DoxyParamCaption}
\item[{{\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a9f219094ea8f9dd6aef7705df253379e}


\-Definition at line 93 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Protoss\-\_\-\-Photon\-\_\-\-Cannon, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Bunker, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Terran\-\_\-\-Missile\-\_\-\-Turret, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Creep\-\_\-\-Colony, \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Spore\-\_\-\-Colony, and \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::\-Zerg\-\_\-\-Sunken\-\_\-\-Colony.



\-Referenced by \-Base\-Class\-::add\-Unit(), \-Building\-Placer\-Class\-::is\-Tile\-Blocked(), \-Base\-Class\-::remove\-Unit(), \-Basic\-Unit\-Action\-::update(), \-Player\-Tracker\-Class\-::update(), and \-Default\-Squad\-Task\-::update().


\begin{DoxyCode}
{
        return(type == BWAPI::UnitTypes::Protoss_Photon_Cannon ||
                type == BWAPI::UnitTypes::Zerg_Creep_Colony ||
                type == BWAPI::UnitTypes::Zerg_Spore_Colony ||
                type == BWAPI::UnitTypes::Zerg_Sunken_Colony ||
                type == BWAPI::UnitTypes::Terran_Bunker ||
                type == BWAPI::UnitTypes::Terran_Missile_Turret);
}
\end{DoxyCode}


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


\hypertarget{namespaceUnitHelper_a2530801f9cfea9bdae1c76c9ed8de083}{\index{\-Unit\-Helper@{\-Unit\-Helper}!tile\-To\-Position@{tile\-To\-Position}}
\index{tile\-To\-Position@{tile\-To\-Position}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{tile\-To\-Position}]{\setlength{\rightskip}{0pt plus 5cm}{\bf \-Position} {\bf \-Unit\-Helper\-::tile\-To\-Position} (
\begin{DoxyParamCaption}
\item[{{\bf \-Tile\-Position}}]{tile, }
\item[{{\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a2530801f9cfea9bdae1c76c9ed8de083}


\-Definition at line 88 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::tile\-Height(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::tile\-Width(), \-B\-W\-A\-P\-I\-::\-Tile\-Position\-::x(), and \-B\-W\-A\-P\-I\-::\-Tile\-Position\-::y().


\begin{DoxyCode}
{
        return Position(tile.x()*32+(type.tileWidth()*16), tile.y()*32+(type.
      tileHeight()*16));
}
\end{DoxyCode}


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


\hypertarget{namespaceUnitHelper_a06f1422c822b556d6faf84d7f321ff24}{\index{\-Unit\-Helper@{\-Unit\-Helper}!unit\-Produces\-Ground@{unit\-Produces\-Ground}}
\index{unit\-Produces\-Ground@{unit\-Produces\-Ground}!UnitHelper@{\-Unit\-Helper}}
\subsubsection[{unit\-Produces\-Ground}]{\setlength{\rightskip}{0pt plus 5cm}bool {\bf \-Unit\-Helper\-::unit\-Produces\-Ground} (
\begin{DoxyParamCaption}
\item[{{\bf \-B\-W\-A\-P\-I\-::\-Unit\-Type}}]{type}
\end{DoxyParamCaption}
)}}\label{namespaceUnitHelper_a06f1422c822b556d6faf84d7f321ff24}


\-Definition at line 5 of file \-Unit\-Helper.\-cpp.



\-References \-B\-W\-A\-P\-I\-::\-Unit\-Types\-::all\-Unit\-Types(), \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::is\-Flyer(), and \-B\-W\-A\-P\-I\-::\-Unit\-Type\-::what\-Builds().



\-Referenced by \-Building\-Placer\-Class\-::is\-Location\-Non\-Blocking().


\begin{DoxyCode}
{
        static std::set<BWAPI::UnitType> unitData;
        if(unitData.empty())
        {
                for each(BWAPI::UnitType type in BWAPI::UnitTypes::allUnitTypes
      ())
                {
                        if(!type.isFlyer() && type.whatBuilds().first.
      isBuilding())
                                unitData.insert(type.whatBuilds().first);
                }
        }

        return unitData.count(type) != 0;
}
\end{DoxyCode}


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




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


