|
|
@ -80,36 +80,36 @@ int Winner(char board[3][3]) { |
|
|
|
printf("Es ist ein Unendschieden\n"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
void makeMove(char board[3][3], int row, int col) { |
|
|
|
void makeMove(char board[3][3], int row, int column) { |
|
|
|
if (Runde < 10) { |
|
|
|
if (Runde % 2 == 0) { |
|
|
|
if (board[row][col] == '_') { |
|
|
|
board[row][col] = 'O'; |
|
|
|
if (board[row][column] == '_') { |
|
|
|
board[row][column] = 'O'; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); |
|
|
|
printf("Reihe:"); |
|
|
|
scanf("%d", &row); |
|
|
|
printf("Spalte:"); |
|
|
|
scanf("%d", &col); |
|
|
|
scanf("%d", &column); |
|
|
|
row -= 1; |
|
|
|
col -= 1; |
|
|
|
makeMove(board, row, col); |
|
|
|
column -= 1; |
|
|
|
makeMove(board, row, column); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (board[row][col] == '_') { |
|
|
|
board[row][col] = 'X'; |
|
|
|
if (board[row][column] == '_') { |
|
|
|
board[row][column] = 'X'; |
|
|
|
} |
|
|
|
else { |
|
|
|
printf("Das Feld ist schon besetzt. Gib ein anderes Feld ein:\n"); |
|
|
|
printf("Reihe:"); |
|
|
|
scanf("%d", &row); |
|
|
|
printf("Spalte:"); |
|
|
|
scanf("%d", &col); |
|
|
|
scanf("%d", &column); |
|
|
|
row -= 1; |
|
|
|
col -= 1; |
|
|
|
makeMove(board, row, col); |
|
|
|
column -= 1; |
|
|
|
makeMove(board, row, column); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -117,7 +117,7 @@ void makeMove(char board[3][3], int row, int col) { |
|
|
|
// Hauptfunktion zum Spielen des Tic Tac Toe-Spiels |
|
|
|
int TicTacToe_ausfuehren() { |
|
|
|
int row; |
|
|
|
int col; |
|
|
|
int column; |
|
|
|
char board[3][3]; |
|
|
|
char Spieler1[50], Spieler2[50]; |
|
|
|
int Punkte1 = 0, Punkte2 = 0; |
|
|
@ -148,16 +148,16 @@ int TicTacToe_ausfuehren() { |
|
|
|
printf("Reihe:"); |
|
|
|
scanf("%d", &row); |
|
|
|
printf("Spalte:"); |
|
|
|
scanf("%d", &col); |
|
|
|
scanf("%d", &column); |
|
|
|
row -= 1; |
|
|
|
col -= 1; |
|
|
|
if (row > 3 || col > 3) { |
|
|
|
column -= 1; |
|
|
|
if (row > 3 || column > 3) { |
|
|
|
printf("Das ist nicht mehr im Feld. Versuch es nochmal:"); |
|
|
|
scanf("%d %d", &row, &col); |
|
|
|
scanf("%d %d", &row, &column); |
|
|
|
row -= 1; //Für Index eins kleiner |
|
|
|
col -= 1; |
|
|
|
column -= 1; |
|
|
|
} |
|
|
|
makeMove(board, row, col); |
|
|
|
makeMove(board, row, column); |
|
|
|
Runde++; |
|
|
|
} |
|
|
|
displayBoard(board); |
|
|
|