Tic Tac Toe 4x4 grid help

Hello i am trying to create tic tac toe game as normal rules but with a 4x4 grid. i have come up with the following and cannot figure out what my problem is! please help, thank you in advance.

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
  #include <iostream>

void main() {
	char cSquare1('1');
	char cSquare2('2');
	char cSquare3('3');
	char cSquare4('4');
	char cSquare5('5');
	char cSquare6('6');
	char cSquare7('7');
	char cSquare8('8');
	char cSquare9('9');
	char cSquare10('10');
	char cSquare11('11');
	char cSquare12('12');
	char cSquare13('13');
	char cSquare14('14');
	char cSquare15('15');
	char cSquare16('16');
	int iPlayerTurn(1);
	bool bGameOver(true);

	// Main game loop
	do {
		// Print board
		std::cout << cSquare1 << "|" << cSquare2 << "|" << cSquare3 << "|" << cSquare4 << std::endl;
		std::cout << "-+-+-+-"<< std::endl;
		std::cout << cSquare5 << "|" << cSquare6 << "|" << cSquare7 << "|" << cSquare8 << std::endl;
		std::cout << "-+-+-+-"<< std::endl;
		std::cout << cSquare9 << "|" << cSquare10 << "|" << cSquare11 << "|" << cSquare12 << std::endl;
		std::cout << "-+-+-+-"<< std::endl;
		std::cout << cSquare13 << "|" << cSquare14 << "|" << cSquare15 << "|" << cSquare16 << std::endl;

		// Set player marker: Player 1 uses X and Player 2 uses O
		char cPlayerMark;
		if (iPlayerTurn == 1) {
			cPlayerMark = 'X';
		} else {
			cPlayerMark = 'O';
		}
		
		// Prompt the player for a move
		std::cout << "Player" << iPlayerTurn << "'s move:" << std::endl;
		bool bValidMove;
		// Loop until we get a valid move
		do {
			char cNextMove;
			std::cin >> cNextMove;
			bValidMove = true;

			// Check for a valid move
			if (cNextMove == '1' && cSquare1 == '1') {
				cSquare1 = cPlayerMark;
			} else if (cNextMove == '2' && cSquare2 == '2') {
				cSquare2 = cPlayerMark;
			} else if (cNextMove == '3' && cSquare3 == '3') {
				cSquare3 = cPlayerMark;
			} else if (cNextMove == '4' && cSquare4 == '4') {
				cSquare4 = cPlayerMark;
			} else if (cNextMove == '5' && cSquare5 == '5') {
				cSquare5 = cPlayerMark;
			} else if (cNextMove == '6' && cSquare6 == '6') {
				cSquare6 = cPlayerMark;
			} else if (cNextMove == '7' && cSquare7 == '7') {
				cSquare7 = cPlayerMark;
			} else if (cNextMove == '8' && cSquare8 == '8') {
				cSquare8 = cPlayerMark;
			} else if (cNextMove == '9' && cSquare9 == '9') {
				cSquare9 = cPlayerMark;
			} else if (cNextMove == '10' && cSquare10 == '10') {
				cSquare10 = cPlayerMark;
			} else if (cNextMove == '11' && cSquare9 == '11') {
				cSquare11 = cPlayerMark;
			} else if (cNextMove == '12' && cSquare12 == '12') {
				cSquare12 = cPlayerMark;
			} else if (cNextMove == '13' && cSquare13 == '13') {
				cSquare13 = cPlayerMark;
			} else if (cNextMove == '14' && cSquare14 == '14') {
				cSquare14 = cPlayerMark;
			} else if (cNextMove == '15' && cSquare15 == '15') {
				cSquare15 = cPlayerMark;
			} else if (cNextMove == '16' && cSquare16 == '16') {
				cSquare16 = cPlayerMark;
			} else {
				std::cout << "Invalid Move. Try again." << std::endl;
				bValidMove = false;
			}
		} while (!bValidMove);

		bGameOver		= false;
		bool bWinGame	= true;
		// Check for end of game conditions
		if (cSquare1 != '1') {
			if (cSquare2 == cSquare1 && cSquare3 == cSquare1) {
				bGameOver = true;
			}
			if (cSquare4 == cSquare1 && cSquare7 == cSquare1) {
				bGameOver = true;
			}
		}
		if (cSquare5 != '5') {
			if (cSquare1 == cSquare5 && cSquare9 == cSquare5) {
				bGameOver = true;
			}
			if (cSquare2 == cSquare5 && cSquare8 == cSquare5) {
				bGameOver = true;
			}
			if (cSquare4 == cSquare5 && cSquare6 == cSquare5) {
				bGameOver = true;
			}
			if (cSquare3 == cSquare5 && cSquare7 == cSquare5) {
				bGameOver = true;
			}
		}
		if (cSquare9 != '9') {
			if (cSquare3 == cSquare9 && cSquare6 == cSquare9) {
				bGameOver = true;
			}
			if (cSquare7 == cSquare9 && cSquare8 == cSquare9) {
				bGameOver = true;
			}
		}
		// Need to check the board full (no-win condition)
		if (cSquare1 != '1' && cSquare2 != '2' && cSquare3 != '3' && cSquare4 != '4'
			cSquare5 != '5' && cSquare6 != '6' && cSquare7 != '7' && cSquare8 != '8'
			cSquare9 != '9' && cSquare10 != '10' && cSquare11 != '11' && cSquare12 != '12'
			cSquare13 != '13' && cSquare14 != '14' && cSquare15 != '15' && cSquare16 != '16' !bGameOver)
		{
			bGameOver = true;
			bWinGame = false;
		}

		if (bGameOver) {
			if (bWinGame) {
				std::cout << "Player" << iPlayerTurn << " wins!" << std::endl;
			}
			// Print ending board
			std::cout << cSquare1 << "|" << cSquare2 << "|" << cSquare3 << "|" << cSquare4 << std::endl;
			std::cout << "-+-+-+-"<< std::endl;
			std::cout << cSquare5 << "|" << cSquare6 << "|" << cSquare7 << "|" << cSquare8 << std::endl;
			std::cout << "-+-+-+-"<< std::endl;
			std::cout << cSquare9 << "|" << cSquare10 << "|" << cSquare11 << "|" << cSquare12 << std::endl;
			std::cout << "-+-+-+-"<< std::endl;
			std::cout << cSquare13 << "|" << cSquare14 << "|" << cSquare15 << "|" << cSquare16 << std::endl;

			std::cout << "Game Over!" << std::endl;
			std::cout << "Play again (y/n)?" << std::endl;
			char cPlayAgain;
			std::cin >> cPlayAgain;

			if (cPlayAgain == 'y') {
				bGameOver = false;
				// Clear the board
				cSquare1 = '1';
				cSquare2 = '2';
				cSquare3 = '3';
				cSquare4 = '4';
				cSquare5 = '5';
				cSquare6 = '6';
				cSquare7 = '7';
				cSquare8 = '8';
				cSquare9 = '9';
				cSquare10 = '10';
				cSquare11 = '11';
				cSquare12 = '12';
				cSquare13 = '13';
				cSquare14 = '14';
				cSquare15 = '15';
				cSquare16 = '16';
			}
			iPlayerTurn = 1;
		} else {
			// Alternate player turns
			if (iPlayerTurn == 1) {
				iPlayerTurn = 2;
			} else {
				iPlayerTurn = 1;
			}
		}
	} while (!bGameOver);
}
Seriously? You come to this forum and over the course of four hours you post the same post five times.


Read this:
http://www.cplusplus.com/forum/beginner/1/

After you've read that, revise your post. You're currently doing nothing but annoying everybody here.
i just want a bit of help or something please! just a push in the right direction?!
Did you read what I posted in your previous thread?
http://www.cplusplus.com/forum/beginner/139989/#msg740168

There is no reason to start a new thread. Whenever there is an update to your thread (including ones you make), your thread moves back to the top.

Topic archived. No new replies allowed.