How would one create a tic-tac-toe game with these instructions?
Along with making sure that the positions a - i will change to 'x' or 'o', once a player makes a move?
#include <vector>
#include <iostream>
using namespace std;
const bool CLEAR_SCREEN = true;
/// @brief Utilizes an escape character sequence to clear the screen
void clearScreen()
{
cout << endl;
if (CLEAR_SCREEN)
{
cout << "\033c";
}
cout << endl;
}
/// @brief Draws the provided tic-tac-toe board to the screen
// @param board is the tic-tac-toe board that should be drawn
void drawBoard(const vector < char >&board)
{
clearScreen();
for (int i = 0; i < 9; i += 3)
{
cout << " " << board.at(i) << " | " << board.at(i + 1) << " | "
<< board.at(i + 2) << " " << endl;
if (i < 6)
cout << "-----|-----|-----" << endl;
}
cout << endl;
}
/// @brief Fills vector with characters starting at lower case a.
///
/// If the vector is size 3 then it will have characters a to c.
/// If the vector is size 5 then it will have characters a to e.
/// If the vector is size 26 then it will have characters a to z.
///
/// @param v the vector to initialize
/// @pre-condition the vector size will never be over 26
void initVector(vector<char> &v)
{
string mapA = "abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < v.size(); i++)
{
v.at(i) = mapA.at(i);
}
}
/// @brief Converts a character representing a cell to associated vector index
/// @param the position to be converted to a vector index
/// @return the integer index in the vector, should be 0 to (vector size - 1)
int convertPosition(char position)
{
// TODO: implement function
return -1;
}