XO - Please Read this and Reply.

A couple of days a go i was stuck with my X & O Game or as i call it Tic Tac Toe xD

Well anyway i got a bit confused and remade the input function.

But i dont think bits of it are correct can you help point some stuff out?...


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void Input(){
    int x, y;
	bool done = false;
	while(done == false)
		cout << "Player 1 please enter the x coordinate...";
		cin >> x;
		cout << "Player 1 please enter the y coordinate...";
		cin >> y;
			if ( x < 1 || x  > 3 || y < 1 || y > 3 )
				done = true;
			else
				if (! XOBoard[x % 3 + y / 3]=' ')
					XOBoard[y][x] = 'X';
				else
					done = true;
}
Last edited on
Please Read this and Reply.

It's good that you pointed that out. Otherwise, regarding the fact that the subject line contains absolutely no useful information at all, thus making it impossible for me to determine whether or not I am interested or capable of answering your question, I would have thought that you simply posted to be ignored.

So, rest assured: I read and replied. Hope that helps.
WoW dude your not a fucking ass.....
at line 12:

! XOBoard[x % 3 + y / 3]=' '

should be
! (XOBoard[x % 3 + y / 3]!=' ' )
or
! (XOBoard[x % 3 + y / 3]==' ' )

Right?
oh thanks i dunno what that bit does my teach told me to stick it in it checks the space to see if theres a X or an O there if not its ok and the player can put there X or O there i think.
I dunno what u mean.
Sorry,I just tell u make a mistake.
The obvious ommision is the {} pair arround the body of the while loop - this may be a typo, but if not it would explain why you are having problems.
The logic of setting done = True also looks wrong.
I guess you want to loop until the user inputs a valid co-ordinate pair, so have modified teh logic to matxh this.
You have not shown the definition of XOBoard, but it look odd to reference it as 1D and 2D in consecutive lines, so modified to a consistent 2D style.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void Input()
{
    int x, y;
    bool done = false;
    while(done == false)
    {              
	cout << "Player 1 please enter the x coordinate...";
	cin >> x;
	cout << "Player 1 please enter the y coordinate...";
	cin >> y;
	if ( x >= 1 && x  <=3  && y >= 1 && y <= 3 )
        {
	   if (XOBoard[y][x]=' ')
          {
	      XOBoard[y][x] = 'X';
  	      done = true;
          }
       }
    }
}
Topic archived. No new replies allowed.