Ok im having trouble with my Tic-Tac-Toe program. I am currently working on the part where the computer reads what move the user did and then moves according to the rules. Now I havn't wrote all of the computers rules yet because I dont know if this is how to do it. When I try to run the program it messes up. Here is the source. I hope Yall can find the problem.
Code:#include <iostream> #include <fstream> #include <string> using namespace std; int x=1; int o=2; void startgame(); void xturn(); void oturn(); int moves[9] = {1,2,3,4,5,6,7,8,9}; int main() { int xx; cout << "Would you like to play a game of Tic-Tac-Toe?" << endl; cout << "1 for yes, and 2 for no" << endl; cin >> xx; if (xx == 1) startgame(); else if ( xx == 2) cout << "Looseer!!!!" << endl; return 0; } void startgame() { int win = 0; int count = 0; int victory = 0; int mover; cout << "Lets play." << endl; cout << "You are X. Press 1-9 to make a move." << endl; for ( count=1; count<=9; count++) { moves[9] = count; // This part of the code is used to deturmine whos move it is. if (moves[1] != false) xturn(); if (moves[2] != false) oturn(); if (moves[3] != false) xturn(); if (moves[4] != false) oturn(); if (moves[5] != false) xturn(); if (moves[6] != false) oturn(); if (moves[7] != false) xturn(); if (moves[8] != false) oturn(); if (moves[9] != false) xturn(); if (count==9) { if (!victory) cout << "DRAW!!" << endl; else if (victory != false) cout << mover << " WINS!!" << endl; } } } void xturn() { cin >> x; cout << "You moved to square " << x; cout << endl; } void oturn() { if (x==1) { o==5; } else if (x==5) o==1; cout << "The computer moved to square " << o; cout << endl; }