Original Post
Hello, I tried creating a function for tic tac toe, that checks possible positions for the computer to win, if its open, the computer wins, but this wont seem to work. The code doesnt generate any errors, but it doesnt work. Please help
void GetCmove(vector<char>& gBoard)
{
int CMove = 0;
bool done = false;
while(!done) {
CMove = rand() % 8;
for(int a = 0; a != 3; a++) {
for(int b = 0; b != 3; b++) {
for(int c = 0; c != 3; c++) {
if(gBoard[a] == 'O' && gBoard == 'O' && gBoard[c] != 'X' && gBoard[c] != 'O') {
gBoard[c] = 'O';
done = true;
}
}
}
}
if(gBoard[CMove] == 'X' || gBoard[CMove] == 'O')
done = false;
else {
gBoard[CMove] = 'O';
done = true;
}
}
}