\doxysection{Four\+Board.\+h}
\hypertarget{_four_board_8h_source}{}\label{_four_board_8h_source}\mbox{\hyperlink{_four_board_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{preprocessor}{\#pragma\ once}}
\DoxyCodeLine{00002\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{_board_game___classes_8h}{BoardGame\_Classes.h}}"{}}}
\DoxyCodeLine{00003\ \textcolor{preprocessor}{\#include\ <vector>}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{keyword}{class\ }\mbox{\hyperlink{class_four_board_a677825ff6faee975e6957d18ce7f5384}{FourBoard}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{class_board_ae5dfded241ee3644196e2f6074d1d0b1}{Board}}<char>\ \{}
\DoxyCodeLine{00006\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00007\ \ \ \ \ \mbox{\hyperlink{class_four_board_a677825ff6faee975e6957d18ce7f5384}{FourBoard}}()\ :\ \mbox{\hyperlink{class_board_ae5dfded241ee3644196e2f6074d1d0b1}{Board}}<char>(6,\ 7)\ \{}
\DoxyCodeLine{00008\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}\ =\ vector<vector<char>>(6,\ vector<char>(7,\ \textcolor{charliteral}{'\ '}));}
\DoxyCodeLine{00009\ \ \ \ \ \}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \ \ \ \ \textcolor{comment}{//\ Update:\ move-\/>get\_y()\ is\ the\ column\ chosen.\ We\ drop\ to\ lowest\ empty\ row.}}
\DoxyCodeLine{00012\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{class_four_board_a0ec38eafc17cedde5ad1550078e0e619}{update\_board}}(\mbox{\hyperlink{class_move}{Move<char>}}*\ m)\textcolor{keyword}{\ override\ }\{}
\DoxyCodeLine{00013\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ col\ =\ m-\/>\mbox{\hyperlink{class_move_a96469802a55c9083a1e93c7edec8a00c}{get\_y}}();}
\DoxyCodeLine{00014\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ sym\ =\ m-\/>\mbox{\hyperlink{class_move_a595bf740852c05a1cb425ef2640fd4ff}{get\_symbol}}();}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (col\ <\ 0\ ||\ col\ >=\ \mbox{\hyperlink{class_board_afaf8842d9d52ac724e8c2f5642ecafc7}{columns}})\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ find\ lowest\ empty\ row\ (largest\ row\ index)}}
\DoxyCodeLine{00019\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ \mbox{\hyperlink{class_board_a948d978e3b5fc460559b588f5dee9572}{rows}}\ -\/\ 1;\ r\ >=\ 0;\ -\/-\/r)\ \{}
\DoxyCodeLine{00020\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][col]\ ==\ \textcolor{charliteral}{'\ '})\ \{}
\DoxyCodeLine{00021\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][col]\ =\ sym;}
\DoxyCodeLine{00022\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{class_board_a5952baefabced65fecec333de638408d}{n\_moves}}++;}
\DoxyCodeLine{00023\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00024\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00025\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00026\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ column\ full}}
\DoxyCodeLine{00027\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00028\ \ \ \ \ \}}
\DoxyCodeLine{00029\ }
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{class_four_board_a49092d1ca89edc02418b2e3be35eda73}{is\_win}}(\mbox{\hyperlink{class_player}{Player<char>}}*\ p)\textcolor{keyword}{\ override\ }\{}
\DoxyCodeLine{00031\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ sym\ =\ p-\/>\mbox{\hyperlink{class_player_af56f0bf98c0423a3a75b0848607d03a4}{get\_symbol}}();}
\DoxyCodeLine{00032\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ check\ 4-\/in-\/a-\/row\ in\ all\ directions}}
\DoxyCodeLine{00033\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ horizontal}}
\DoxyCodeLine{00034\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ 0;\ r\ <\ \mbox{\hyperlink{class_board_a948d978e3b5fc460559b588f5dee9572}{rows}};\ ++r)\ \{}
\DoxyCodeLine{00035\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ +\ 3\ <\ \mbox{\hyperlink{class_board_afaf8842d9d52ac724e8c2f5642ecafc7}{columns}};\ ++c)\ \{}
\DoxyCodeLine{00036\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c\ +\ 1]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c\ +\ 2]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c\ +\ 3]\ ==\ sym)}
\DoxyCodeLine{00037\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00038\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ vertical}}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ <\ \mbox{\hyperlink{class_board_afaf8842d9d52ac724e8c2f5642ecafc7}{columns}};\ ++c)\ \{}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ 0;\ r\ +\ 3\ <\ \mbox{\hyperlink{class_board_a948d978e3b5fc460559b588f5dee9572}{rows}};\ ++r)\ \{}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ +\ 1][c]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ +\ 2][c]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ +\ 3][c]\ ==\ sym)}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00047\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ diagonal\ down-\/right}}
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ 0;\ r\ +\ 3\ <\ \mbox{\hyperlink{class_board_a948d978e3b5fc460559b588f5dee9572}{rows}};\ ++r)\ \{}
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ +\ 3\ <\ \mbox{\hyperlink{class_board_afaf8842d9d52ac724e8c2f5642ecafc7}{columns}};\ ++c)\ \{}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ +\ 1][c\ +\ 1]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ +\ 2][c\ +\ 2]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ +\ 3][c\ +\ 3]\ ==\ sym)}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ diagonal\ up-\/right}}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ 3;\ r\ <\ \mbox{\hyperlink{class_board_a948d978e3b5fc460559b588f5dee9572}{rows}};\ ++r)\ \{}
\DoxyCodeLine{00056\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ +\ 3\ <\ \mbox{\hyperlink{class_board_afaf8842d9d52ac724e8c2f5642ecafc7}{columns}};\ ++c)\ \{}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ -\/\ 1][c\ +\ 1]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ -\/\ 2][c\ +\ 2]\ ==\ sym\ \&\&\ \mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r\ -\/\ 3][c\ +\ 3]\ ==\ sym)}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00062\ \ \ \ \ \}}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{class_four_board_ae18d8b2509b8066c23516ef838eef9c1}{is\_draw}}(\mbox{\hyperlink{class_player}{Player<char>}}*\ p)\textcolor{keyword}{\ override\ }\{}
\DoxyCodeLine{00065\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ draw\ if\ board\ full\ and\ no\ winner}}
\DoxyCodeLine{00066\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ 0;\ r\ <\ \mbox{\hyperlink{class_board_a948d978e3b5fc460559b588f5dee9572}{rows}};\ ++r)}
\DoxyCodeLine{00067\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ <\ \mbox{\hyperlink{class_board_afaf8842d9d52ac724e8c2f5642ecafc7}{columns}};\ ++c)}
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\mbox{\hyperlink{class_board_af00c1fc363eb640ca276b8a572040040}{board}}[r][c]\ ==\ \textcolor{charliteral}{'\ '})}
\DoxyCodeLine{00069\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};}
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};}
\DoxyCodeLine{00071\ \ \ \ \ \}}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00073\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{class_four_board_a5a3cffcd7cd2f4a480558dad05854da7}{is\_lose}}(\mbox{\hyperlink{class_player}{Player<char>}}*\ p)\textcolor{keyword}{\ override\ }\{\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{false};\ \}}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{class_four_board_a43c4eef54ce72b6a593c8d84d105cf3f}{game\_is\_over}}(\mbox{\hyperlink{class_player}{Player<char>}}*\ p)\textcolor{keyword}{\ override\ }\{}
\DoxyCodeLine{00076\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \mbox{\hyperlink{class_four_board_a49092d1ca89edc02418b2e3be35eda73}{is\_win}}(p)\ ||\ \mbox{\hyperlink{class_four_board_ae18d8b2509b8066c23516ef838eef9c1}{is\_draw}}(p);}
\DoxyCodeLine{00077\ \ \ \ \ \}}
\DoxyCodeLine{00078\ \};}

\end{DoxyCode}
