9 template <
class T,
class U>
11 for (
const pair <T,U> & Val : AMap) cout <<
"Cle : " << Val.first <<
" " <<
"Valeur : " << Val.second << endl;
17 char car = Mat [Pos.first][Pos.second];
18 Mat [Pos.first][Pos.second] =
KEmpty;
50 Mat [Pos.first][Pos.second] = car;
57 const unsigned KSize (10);
58 unsigned PartyNum (1);
59 const unsigned KMaxPartyNum (KSize * KSize);
62 bool Player1Turn (
true);
68 InitGrid(Mat, 10, 10, PosPlayer1, PosPlayer2);
72 while (PartyNum <= KMaxPartyNum && ! Victory)
75 cout <<
"tour numero : " << PartyNum <<
", Joueur" 76 << (Player1Turn ?
'1' :
'2') <<
", entrez un déplacement : ";
81 Move = toupper (Move);
82 MoveToken (Mat, Move, (Player1Turn ? PosPlayer1: PosPlayer2));
87 if (PosPlayer1 == PosPlayer2) Victory =
true;
93 Player1Turn = !Player1Turn;
99 cout <<
"Aucun vainqueur" << endl;
104 cout <<
"Félicitations Joueur" << (Player1Turn ?
'2' :
'1')
105 <<
" vous avez gagné :)" << endl;
const char KEmpty
KEmpty : character for an empty cell.
void Color(const string &Col)
void ClearScreen()
Clear the current terminal.
Set of usefull functions for the game.
std::pair< unsigned, unsigned > CPosition
CPosition : a pair gathering the coordinates in the grid.
Paramters' definition and associated functions.
std::vector< CVLine > CMat
CMat : alias to a game grid type.
const std::map< std::string, std::string > KColor
KColor : map between the "human" color and its correspondence for the Unix terminal.
void DisplayGrid(const CMat &Mat)
void ShowMap(const map< T, U > &AMap)
Set of usefull functions for the grid management.
void InitGrid(CMat &Mat, unsigned NbLine, unsigned NbColumn, CPosition &PosPlayer1, CPosition &PosPlayer2)
void MoveToken(CMat &Mat, const char &Move, CPosition &Pos)
Move the current token according to the character in the 2nd parameter.