### tic tac toe

so in the midst of creating this tic tac toe game,i have this problem.it goes like this.
TURN 1
when the player picks the number 4,the computer will choose the number 2.
and when the player picks anything other than 4,the computer will choose 4.
TURN 2
the computer will try to intercept you to prevent you from winning.

so the problem is that when i pick any number other than 4,the computer will not choose 4 but instead jump to the options in turn 2.i cant seem to figure out why.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213`` `````` #include #include #include using namespace std; // ArrayDemo - demonstrate the use of arrays // by reading a sequence of integers // and then displaying them and their sum void tictactoe(void); int gamemode(void);//to select single or multiplayer int singleplayer(void); int multiplayer(void); int main(int nNumberofArgs, char* pszArgs[]) { cout<<"TIC TAC TOE"<>PlayerMove; if((PlayerMove>8)||(PlayerMove<0)) { cout<<"invalid position."<>option; if((option == 1) || (option == 2)) { return option; break; } cout<<"invalid option"<
One problem are the braces of the if on line 102. The if body contains the second check of `turn` on line 121 which will never be true.
Topic archived. No new replies allowed.