Tic-Tac-Toe.

Hi, I am trying to code a tic-tac-toe game, yet every time I attempt to change the turn of the character so it pastes 'x' instead of 'o' it always seems to stay on one characters turn, any suggestions on where I have gone wrong?

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
#include <iostream>
#include <string>
using namespace std;

int main(){
string Player1;
string Player2;
bool Game = true;
char x = 'x';
char o = 'o';
bool Player_Turn=false;
int Playerchoice = 0;
int Playerturn = 1;
char board[3][3] = {{ '1', '2', '3'},{'4', '5', '6'},{'7', '8', '9'}};

// Start of entering players name
cout << "Enter the name of Player 1" << endl;
getline (cin, Player1);

cout << "Enter the name of Player 2" << endl;
getline (cin, Player2);

cout << Player1 << ": shall play as " << x << endl;
cout << Player2 << ": shall play as " << o << endl;
// End of players names and instructions


while (Game=true) // infinite loop
{
	Player_Turn = !Player_Turn;

	cout << "If someone has won, restart the game to play again!" << endl;
	
	
		// Board 
for (int row = 0; row < 3; ++row)
{
    for (int col = 0; col < 3; ++col) // produces 3x col & 3x row, and cout's with | in between.
	{
        cout << board[row][col] << " | ";
    }
    cout << endl;
}
// Board End



		if (Player_Turn = true)
		{

cout << Player1 << ", it is your turn, enter the number of where you would like to go." << endl;
		cin >> Playerchoice;

if (Playerchoice == 1)
{
	board[0][0] = 'x';
}

if (Playerchoice == 2)
{
	board[0][1] = 'x';
}

if (Playerchoice == 3)
{
	board[0][2] = 'x';
}

if (Playerchoice == 4)
{
	board[1][0] = 'x';
}

if (Playerchoice == 5)
{
	board[1][1] = 'x';
}

if (Playerchoice == 6)
{
	board[1][2] = 'x';
}

if (Playerchoice == 7)
{
	board[2][0] = 'x';
}

if (Playerchoice == 8)
{
	board[2][1] = 'x';
}

if (Playerchoice == 9)
{
	board[2][2] = 'x';
}

}

if (Player_Turn = false)
{

	cout << Player2 << ", it is your turn, enter the number of where you would like to go." << endl;
		cin >> Playerchoice;

if (Playerchoice == 1)
{
	board[0][0] = 'o';
}

if (Playerchoice == 2)
{
	board[0][1] = 'o';
}

if (Playerchoice == 3)
{
	board[0][2] = 'o';
}

if (Playerchoice == 4)
{
	board[1][0] = 'o';
}

if (Playerchoice == 5)
{
	board[1][1] = 'o';
}

if (Playerchoice == 6)
{
	board[1][2] = 'o';
}

if (Playerchoice == 7)
{
	board[2][0] = 'o';
}

if (Playerchoice == 8)
{
	board[2][1] = 'o';
}

if (Playerchoice == 9)
{
	board[2][2] = 'o';
}

}

	


}



return 0;
}
Lines 48 and 101 use assignment as opposed to comparison. Are you sure that's right?
Ah, and there the problem lies! Thanks.
Topic archived. No new replies allowed.