|
@ -69,59 +69,59 @@ int wasGameWon(char field[3][3]){ |
|
|
if (field[0][0] == field[0][1] && field[0][2] == field[0][1]){ |
|
|
if (field[0][0] == field[0][1] && field[0][2] == field[0][1]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
else if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
|
|
|
|
|
|
if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
else if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
|
|
|
|
|
|
if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(field[2][2] == 'O'){ |
|
|
|
|
|
|
|
|
if(field[2][2] == 'O'){ |
|
|
if (field[2][2] == field[2][1] && field[2][2] == field[2][0]){ |
|
|
if (field[2][2] == field[2][1] && field[2][2] == field[2][0]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
else if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
|
|
|
|
|
|
if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(field[1][1] == 'O'){ |
|
|
|
|
|
|
|
|
if(field[1][1] == 'O'){ |
|
|
if (field[1][1] == field[0][1] && field[0][1] == field[2][1]){ |
|
|
if (field[1][1] == field[0][1] && field[0][1] == field[2][1]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
else if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
|
|
|
|
|
|
if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
else if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
|
|
|
|
|
|
if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
winner = PLAYER; |
|
|
winner = PLAYER; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(field[0][0] == 'X'){ |
|
|
|
|
|
|
|
|
if(field[0][0] == 'X'){ |
|
|
if (field[0][0] == field[0][1] && field[0][2] == field[0][1]){ |
|
|
if (field[0][0] == field[0][1] && field[0][2] == field[0][1]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
else if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
|
|
|
|
|
|
if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
else if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
|
|
|
|
|
|
if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(field[2][2] == 'X'){ |
|
|
|
|
|
|
|
|
if(field[2][2] == 'X'){ |
|
|
if (field[2][2] == field[2][1] && field[2][2] == field[2][0]){ |
|
|
if (field[2][2] == field[2][1] && field[2][2] == field[2][0]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
else if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
|
|
|
|
|
|
if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if(field[1][1] == 'X'){ |
|
|
|
|
|
|
|
|
if(field[1][1] == 'X'){ |
|
|
if (field[1][1] == field[0][1] && field[0][1] == field[2][1]){ |
|
|
if (field[1][1] == field[0][1] && field[0][1] == field[2][1]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
else if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
|
|
|
|
|
|
if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
else if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
|
|
|
|
|
|
if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
winner = COMPUTER; |
|
|
winner = COMPUTER; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|