\doxysection{Four\+UI.\+h}
\hypertarget{_four_u_i_8h_source}{}\label{_four_u_i_8h_source}\mbox{\hyperlink{_four_u_i_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\ "{}\mbox{\hyperlink{_four_board_8h}{FourBoard.h}}"{}}}
\DoxyCodeLine{00004\ \textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#include\ <random>}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#include\ <chrono>}}
\DoxyCodeLine{00007\ \textcolor{keyword}{class\ }\mbox{\hyperlink{class_four_u_i_aa08f3e2aaf9ad7499a43a6cc098a3a1d}{FourUI}}\ :\ \textcolor{keyword}{public}\ \mbox{\hyperlink{class_u_i_ae50eed41905ca2f8dc103d9bef427fe6}{UI}}<char>\ \{}
\DoxyCodeLine{00008\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00009\ \ \ \ \ \mbox{\hyperlink{class_four_u_i_aa08f3e2aaf9ad7499a43a6cc098a3a1d}{FourUI}}()\ :\ \mbox{\hyperlink{class_u_i_ae50eed41905ca2f8dc103d9bef427fe6}{UI}}(\textcolor{stringliteral}{"{}Four-\/in-\/a-\/row\ (6x7)"{}},\ 2)\ \{\}}
\DoxyCodeLine{00010\ \ \ \ \ \textcolor{keywordtype}{void}\ \mbox{\hyperlink{class_four_u_i_ae8c16e62354c51a78f7a5a5205c2edaa}{print\_board}}(\textcolor{keyword}{const}\ vector<vector<char>>\&\ b)\ \{}
\DoxyCodeLine{00011\ \ \ \ \ \ \ \ \ cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)nColumns:\ "{}};}
\DoxyCodeLine{00012\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ <\ (int)b[0].size();\ ++c)\ cout\ <<\ c\ <<\ \textcolor{charliteral}{'\ '};}
\DoxyCodeLine{00013\ \ \ \ \ \ \ \ \ cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)n-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/\(\backslash\)n"{}};}
\DoxyCodeLine{00014\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ r\ =\ 0;\ r\ <\ (int)b.size();\ ++r)\ \{}
\DoxyCodeLine{00015\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ <\ (int)b[r].size();\ ++c)\ \{}
\DoxyCodeLine{00016\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{char}\ ch\ =\ b[r][c];}
\DoxyCodeLine{00017\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cout\ <<\ (ch\ ==\ \textcolor{charliteral}{'\ '}\ ?\ \textcolor{charliteral}{'.'}\ :\ ch)\ <<\ \textcolor{charliteral}{'\ '};}
\DoxyCodeLine{00018\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00019\ \ \ \ \ \ \ \ \ \ \ \ \ cout\ <<\ \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{00020\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00021\ \ \ \ \ \ \ \ \ cout\ <<\ endl;}
\DoxyCodeLine{00022\ \ \ \ \ \}}
\DoxyCodeLine{00023\ \ \ \ \ \mbox{\hyperlink{class_move}{Move<char>}}*\ \mbox{\hyperlink{class_four_u_i_a210c7b394756f34acc72f9b31ba6665e}{get\_move}}(\mbox{\hyperlink{class_player}{Player<char>}}*\ p)\textcolor{keyword}{\ override\ }\{}
\DoxyCodeLine{00024\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{class_four_board}{FourBoard}}*\ bptr\ =\ \textcolor{keyword}{dynamic\_cast<}\mbox{\hyperlink{class_four_board}{FourBoard}}*\textcolor{keyword}{>}(p-\/>\mbox{\hyperlink{class_player_a508617eddfae8915d098102d480fc888}{get\_board\_ptr}}());}
\DoxyCodeLine{00025\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!bptr)\ \{}
\DoxyCodeLine{00026\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ r,\ c;\ \textcolor{keywordtype}{char}\ s;}
\DoxyCodeLine{00027\ \ \ \ \ \ \ \ \ \ \ \ \ cin\ >>\ r\ >>\ c\ >>\ s;}
\DoxyCodeLine{00028\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{class_move}{Move<char>}}(r,\ c,\ s);}
\DoxyCodeLine{00029\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ matrix\ =\ bptr-\/>\mbox{\hyperlink{class_board_a117f2e61fdb7deccca333bbbc9c62d3a}{get\_board\_matrix}}();}
\DoxyCodeLine{00032\ \ \ \ \ \ \ \ \ \mbox{\hyperlink{class_four_u_i_ae8c16e62354c51a78f7a5a5205c2edaa}{print\_board}}(matrix);}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (p-\/>\mbox{\hyperlink{class_player_a2df3bd299bf7aecfa2275ec6902a60f8}{get\_type}}()\ ==\ \mbox{\hyperlink{_board_game___classes_8h_abe590f3c9109f404f003d5d7e4f0fccfad19cbc472227d1e3d1d276c2cbc0e513}{PlayerType::COMPUTER}})\ \{}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ \ \ \ \ \ \ \ \ \ \ \ \ vector<int>\ validCols;}
\DoxyCodeLine{00037\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ c\ =\ 0;\ c\ <\ bptr-\/>\mbox{\hyperlink{class_board_ac665e1ed1f49125fab248e2c9ddfd608}{get\_columns}}();\ ++c)\ \{}
\DoxyCodeLine{00038\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (matrix[0][c]\ ==\ \textcolor{charliteral}{'\ '})\ validCols.push\_back(c);}
\DoxyCodeLine{00039\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00040\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (validCols.empty())\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{class_move}{Move<char>}}(0,\ 0,\ p-\/>\mbox{\hyperlink{class_player_af56f0bf98c0423a3a75b0848607d03a4}{get\_symbol}}());}
\DoxyCodeLine{00041\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{static}\ std::mt19937\ rng((\textcolor{keywordtype}{unsigned})chrono::high\_resolution\_clock::now().time\_since\_epoch().count());}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \ \ \ \ std::uniform\_int\_distribution<int>\ dist(0,\ (\textcolor{keywordtype}{int})validCols.size()\ -\/\ 1);}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ col\ =\ validCols[dist(rng)];}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \ \ \ \ cout\ <<\ \textcolor{stringliteral}{"{}Computer\ "{}}\ <<\ p-\/>\mbox{\hyperlink{class_player_aed2af19790ba73190e3ebeea589518e1}{get\_name}}()\ <<\ \textcolor{stringliteral}{"{}\ plays\ column\ "{}}\ <<\ col\ <<\ \textcolor{charliteral}{'\(\backslash\)n'};}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{class_move}{Move<char>}}(0,\ col,\ p-\/>\mbox{\hyperlink{class_player_af56f0bf98c0423a3a75b0848607d03a4}{get\_symbol}}());\ }
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00048\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{while}\ (\textcolor{keyword}{true})\ \{}
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ col;}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \ \ \ \ cout\ <<\ p-\/>\mbox{\hyperlink{class_player_aed2af19790ba73190e3ebeea589518e1}{get\_name}}()\ <<\ \textcolor{stringliteral}{"{}\ enter\ column\ (0-\/"{}}\ <<\ (bptr-\/>\mbox{\hyperlink{class_board_ac665e1ed1f49125fab248e2c9ddfd608}{get\_columns}}()\ -\/\ 1)\ <<\ \textcolor{stringliteral}{"{}):\ "{}};}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (!(cin\ >>\ col))\ \{\ cin.clear();\ \textcolor{keywordtype}{string}\ garbage;\ getline(cin,\ garbage);\ cout\ <<\ \textcolor{stringliteral}{"{}Invalid\ input\(\backslash\)n"{}};\ \textcolor{keywordflow}{continue};\ \}}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (col\ <\ 0\ ||\ col\ >=\ bptr-\/>\mbox{\hyperlink{class_board_ac665e1ed1f49125fab248e2c9ddfd608}{get\_columns}}())\ \{\ cout\ <<\ \textcolor{stringliteral}{"{}Column\ out\ of\ range\(\backslash\)n"{}};\ \textcolor{keywordflow}{continue};\ \}}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (matrix[0][col]\ !=\ \textcolor{charliteral}{'\ '})\ \{\ cout\ <<\ \textcolor{stringliteral}{"{}Column\ full.\ Choose\ another.\(\backslash\)n"{}};\ \textcolor{keywordflow}{continue};\ \}}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{class_move}{Move<char>}}(0,\ col,\ p-\/>\mbox{\hyperlink{class_player_af56f0bf98c0423a3a75b0848607d03a4}{get\_symbol}}());}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00056\ \ \ \ \ \}}
\DoxyCodeLine{00057\ }
\DoxyCodeLine{00058\ \ \ \ \ \mbox{\hyperlink{class_player}{Player<char>}}*\ \mbox{\hyperlink{class_four_u_i_aa608f5a529dc94504ac16e9ce43d1b0e}{create\_player}}(\textcolor{keywordtype}{string}\&\ name,\ \textcolor{keywordtype}{char}\ symbol,\ \mbox{\hyperlink{_board_game___classes_8h_abe590f3c9109f404f003d5d7e4f0fccf}{PlayerType}}\ type)\textcolor{keyword}{\ override\ }\{}
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{new}\ \mbox{\hyperlink{class_player}{Player<char>}}(name,\ symbol,\ type);}
\DoxyCodeLine{00060\ \ \ \ \ \}}
\DoxyCodeLine{00061\ \};}

\end{DoxyCode}
