tic tac toe game

Working on a flexible tic tac toe game. Having trouble with the logic for whether or not a space is occupied. They're in the functions turnO() and turnX(). Sometimes it will overwrite an X or O other times it will say it's occupied. Any feedback is appreciated. The CG_LINE etc. macros are on another header file, they are just being used to display extended ASCII characters. That's all that's on the other header file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189



#include  <iostream>
#include  "consoleGraphics.h"


#define BOARD_SIZE  3



using  namespace  std;

void trackBoard(int row , int col , int boardDim [][BOARD_SIZE])
{
	int forceSpace = -999;

	if (col >= BOARD_SIZE )
	{
		col = forceSpace;
		cout << " ";
	}
	 if (row >= BOARD_SIZE )
	{
		row =  forceSpace;
		cout << " ";
	}
	if (boardDim[row][col] == 1)
		cout << "X";

	else if (boardDim[row][col] ==2)
		cout << "O";
	else
		cout << " ";
}

void popGrid(int grid[])
{
    for(int inc=0 ; inc < BOARD_SIZE ; ++inc)
    grid [inc] = inc +1;

}


void drawBoard(int grid[] , int boardDim [][BOARD_SIZE])
{
    cout << " ";
    for(int inc=0 ; inc < BOARD_SIZE ; ++inc)
        cout << " " << grid[inc] ;
        cout << endl << " ";

    for(int inc=0 ; inc < BOARD_SIZE * 2 + 1 ; ++inc)
        cout << CG_LINE_HOR ;
		cout << endl ;

       int num = 0;

    for(int inc=0 ; inc < BOARD_SIZE-1 ; ++inc)		// num = row  inc = col
        {
         cout << grid[num];
         ++ num;
         for(int i=0 ; i < BOARD_SIZE + 1 ; ++i)
		 {
         cout << CG_LINE_VERT;
		 trackBoard(num -1 , i , boardDim) ;
		 }
         cout << endl;
		 cout << " ";
		 //trackBoard(num -1 , inc , boardDim);
		 cout << CG_LINE_VERT ;

         for(int inc=0 ; inc < BOARD_SIZE -1 ; ++inc)
		 
         cout << CG_LINE_HOR << CG_CROSS;
         cout << CG_LINE_HOR << CG_LINE_VERT << endl;
        }

   cout << grid [num] ;

   int inc = 0;
        for(int inc=0 ; inc < BOARD_SIZE + 1 ; ++inc)
		 {
         cout << CG_LINE_VERT;
		 trackBoard(num , inc , boardDim) ;
		 }
        cout << endl;
		cout << " ";
	    //trackBoard(num , inc , boardDim);

        for(int inc=0 ; inc < BOARD_SIZE * 2 + 1 ; ++inc)
        cout << CG_LINE_HOR ;
		cout << endl;
}


void turnX(int grid[] , int score[][BOARD_SIZE])
{
	int row;
	int col;
	char comma = ',';
	
    cout << "X- Enter row,col: ";
	cin >> row >> comma >> col;

	while (score[row-1][col-1] == 0 || 2 || 1)
	{
		
	if (score[row-1][col-1] != 2 || 1 )
	{
		score[row - 1][col - 1] = 1;
	break;
	}
	else
	{
		cout << "Space is occupied." << endl;
		cout << "X- Enter row,col: ";
	cin >> row >> comma >> col;
	
	}
	}
	drawBoard(grid , score);

}

void turnO(int grid[] , int score[][BOARD_SIZE])
{
	int row;
	int col;
	char comma = ',';
	
	cout << "O- Enter row,col: ";
	cin >> row >> comma >> col;
    
	while (score[row-1][col-1] == 0 || 1 || 2)
	{
		
	if (score[row-1][col-1] != 1 || 2)
	{
	score[row - 1][col - 1] = 2;
	break;	
		
	}
	else
	{
		cout << "Space is occupied." << endl;
		cout << "O- Enter row,col: ";
	cin >> row >> comma >> col;
	
	}
	}
	score[row - 1][col - 1] = 2;
	drawBoard(grid , score);

}

//
// Main program
//
int  main()
{

  int boardDim[BOARD_SIZE][BOARD_SIZE] = {0};
  int grid[BOARD_SIZE] = {0};
  int y=1;
  popGrid(grid);

  while (y != 0)
  {
  drawBoard(grid , boardDim);
  turnX(grid , boardDim);
  turnO(grid , boardDim);






  //Remove this lower portion when done
  for (int inc=0 ; inc < BOARD_SIZE ; ++inc)
  {for (int i = 0 ; i < BOARD_SIZE ; ++ i)
  {cout << boardDim[inc][i] ;
  }
  cout <<endl;
  }
  }


  return  0;
}
Also, any general feedback is welcome as well.
Topic archived. No new replies allowed.