\hypertarget{invader_grids_8cpp_source}{}\doxysection{invader\+Grids.\+cpp}
\label{invader_grids_8cpp_source}\index{src/invaderGrids.cpp@{src/invaderGrids.cpp}}
\mbox{\hyperlink{invader_grids_8cpp}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00001}00001 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00011}00011 \textcolor{preprocessor}{\#include<iostream>}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00012}00012 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{invaders_grid_8h}{invadersGrid.h}}"{}}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00013}00013 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00014}\mbox{\hyperlink{class_invaders_column_ac21ea06c4b99ae790c5f69b0b70986be}{00014}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{class_invaders_column_ac21ea06c4b99ae790c5f69b0b70986be}{InvadersColumn::hasNoValid}}()\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00015}00015     \textcolor{keywordflow}{return} \mbox{\hyperlink{class_invaders_column_a712fad2377c0113268e94d4c90f688ec}{getOutterInvader}}()==size();}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00016}00016 \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00017}00017 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00018}\mbox{\hyperlink{class_invaders_column_a712fad2377c0113268e94d4c90f688ec}{00018}} \textcolor{keywordtype}{unsigned} \mbox{\hyperlink{class_invaders_column_a712fad2377c0113268e94d4c90f688ec}{InvadersColumn::getOutterInvader}}()\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00019}00019     \textcolor{keywordtype}{unsigned} i=size();}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00020}00020     \textcolor{keywordflow}{while}(i>0)\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00021}00021         -\/-\/i;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00022}00022         \textcolor{keywordflow}{if}(at(i)!=\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018ab50339a10e1de285ac99d4c3990b8693}{InvaderType::NONE}})\textcolor{keywordflow}{return} i;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00023}00023     \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00024}00024     \textcolor{keywordflow}{return} size();}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00025}00025 \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00026}00026 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00027}00027 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00028}00028 \textcolor{comment}{// these are used to invoke rand() as less as possible}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00029}00029 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00030}\mbox{\hyperlink{class_invaders_column_a098a2125b23fd3f7db24920cf173f35e}{00030}} \textcolor{keywordtype}{unsigned} \mbox{\hyperlink{class_invaders_column_a098a2125b23fd3f7db24920cf173f35e}{InvadersColumn::randomValidInv}}()\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00031}00031 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00032}00032 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00033}00033     \textcolor{keywordtype}{unsigned} validTotal = 0;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00034}00034     \textcolor{keywordflow}{for}(\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018}{InvaderType}} ite : *\textcolor{keyword}{this})\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00035}00035         \textcolor{keywordflow}{if}(ite!=\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018ab50339a10e1de285ac99d4c3990b8693}{InvaderType::NONE}})++validTotal;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00036}00036     \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00037}00037 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00038}00038     \textcolor{keywordtype}{unsigned} rd = rand() \% validTotal;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00039}00039 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00040}00040     \textcolor{keywordtype}{unsigned} validIndex = 0;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00041}00041     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<size();++i)\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00042}00042         \textcolor{keywordflow}{if}(at(i)!=\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018ab50339a10e1de285ac99d4c3990b8693}{InvaderType::NONE}})\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00043}00043             \textcolor{keywordflow}{if}(validIndex==rd)\textcolor{keywordflow}{return} i;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00044}00044             ++validIndex;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00045}00045         \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00046}00046     \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00047}00047     \textcolor{keywordflow}{throw} runtime\_error(\textcolor{stringliteral}{"{}SHOULD NOT HAPPEN : see randomValidInv()"{}});}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00048}00048 \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00049}00049 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00050}\mbox{\hyperlink{class_invaders_grid_ad327fc6f3a003e65ff3c131698ca6982}{00050}} \textcolor{keywordtype}{unsigned} \mbox{\hyperlink{class_invaders_grid_ad327fc6f3a003e65ff3c131698ca6982}{InvadersGrid::validColsNumber}}()\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00051}00051     \textcolor{keywordtype}{unsigned} validTotal = 0;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00052}00052     \textcolor{keywordflow}{for}(\textcolor{keyword}{const} \mbox{\hyperlink{class_invaders_column}{InvadersColumn}}\& i : *\textcolor{keyword}{this})\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00053}00053         \textcolor{keywordflow}{if}(!i.\mbox{\hyperlink{class_invaders_column_ac21ea06c4b99ae790c5f69b0b70986be}{hasNoValid}}())++validTotal;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00054}00054     \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00055}00055     \textcolor{keywordflow}{return} validTotal;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00056}00056 \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00057}00057 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00058}\mbox{\hyperlink{class_invaders_grid_ac184c30c8a60fdbe8abed9b9455d35d2}{00058}} \textcolor{keywordtype}{unsigned} \mbox{\hyperlink{class_invaders_grid_ac184c30c8a60fdbe8abed9b9455d35d2}{InvadersGrid::randomValidCol}}()\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00059}00059 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00060}00060 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00061}00061 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00062}00062     \textcolor{keywordtype}{unsigned} rd = rand() \% \mbox{\hyperlink{class_invaders_grid_ad327fc6f3a003e65ff3c131698ca6982}{validColsNumber}}();}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00063}00063 }
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00064}00064     \textcolor{keywordtype}{unsigned} validIndex = 0;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00065}00065     \textcolor{keywordflow}{for}(\textcolor{keywordtype}{unsigned} i=0;i<size();++i)\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00066}00066         \textcolor{keywordflow}{if}(!at(i).hasNoValid())\{}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00067}00067             \textcolor{keywordflow}{if}(validIndex==rd)\textcolor{keywordflow}{return} i;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00068}00068             ++validIndex;}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00069}00069         \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00070}00070     \}}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00071}00071     \textcolor{keywordflow}{throw} runtime\_error(\textcolor{stringliteral}{"{}SHOULD NOT HAPPEN : see randomValidCol()"{}});}
\DoxyCodeLine{\Hypertarget{invader_grids_8cpp_source_l00072}00072 \}}

\end{DoxyCode}
