Крестики нолики Сделать вместо второго игрока бота который будет ходить как второй игрок.
#include
using namespace std;
int main() {
setlocale(0, "ru");
string A[3] = { "NULL","NULL", "NULL", };
string B[3] = { "NULL","NULL","NULL", };
string C[3] = { "NULL","NULL","NULL", };
int num = 0;
string gg;
while (true) {
// lable для возращения
reset:
// Спрашиваем у пользователя клетку
cout > gg;
// Проверка на повторный 0 на одну и туже клетку
if (gg == "A1" && A[0] == "0") {
cout > gg;
if (gg == "A1" && A[0] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "A2" && A[1] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "A3" && A[2] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "B1" && B[0] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "B2" && B[1] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "B3" && B[2] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "C1" && C[0] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "C2" && C[1] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "C3" && C[2] == "1") {
cout << "Нельзя ходить" << endl;
goto Res;
}
if (gg == "A1" && A[0] == "NULL") {
A[0] = "1";
}
else if (gg == "A2" && A[1] == "NULL") {
A[1] = "1";
}
else if (gg == "A3" && A[2] == "NULL") {
A[2] = "1";
}
else if (gg == "B1" && B[0] == "NULL") {
B[0] = "1";
}
else if (gg == "B2" && B[1] == "NULL") {
B[1] = "1";
}
else if (gg == "B3" && B[2] == "NULL") {
B[2] = "1";
}
else if (gg == "C1" && C[0] == "NULL") {
C[0] = "1";
}
else if (gg == "C2" && C[1] == "NULL") {
C[1] = "1";
}
else if (gg == "C3" && C[2] == "NULL") {
C[2] = "1";
}
else if (gg != "A1" && gg != "A2" && gg != "A3" && gg != "B1" && gg != "B2" && gg != "B3" && gg != "C1" && gg != "C2" && gg != "C3") {
cout << "Вы вышли за диапазон!" << endl;
goto Res;
}
if (A[0] == "1" && A[1] == "1" && A[2] == "1") {
cout << "Победил 1" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (A[0] == "1" && B[0] == "1" && C[0] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (A[0] == "1" && B[1] == "1" && C[2] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (B[0] == "1" && B[1] == "1" && B[2] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (C[0] == "1" && C[1] == "1" && C[2] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (C[0] == "1" && B[1] == "1" && A[2] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (A[2] == "1" && B[2] == "1" && C[2] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (B[1] == "1" && A[1] == "1" && C[1] == "1") {
cout << "Победил X" << endl;
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
break;
}
if (gg == "A1" && A[0] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "A2" && A[1] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "A3" && A[2] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "B1" && B[0] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "B2" && B[1] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "B3" && B[2] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "C1" && C[0] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "C2" && C[1] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
else if (gg == "C3" && C[2] == "0") {
cout << "Нельзя ходить" << endl;
goto Res;
}
cout << A[0] << "\t" << A[1] << "\t" << A[2] << "\n";
cout << B[0] << "\t" << B[1] << "\t" << B[2] << "\n";
cout << C[0] << "\t" << C[1] << "\t" << C[2] << "\n";
}
}
вот исходный код
Мда