fix swapped x and y coordinates

This commit is contained in:
2026-04-04 21:34:13 +02:00
parent 12eba69eb1
commit 610bc1c07c
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -111,12 +111,12 @@ static char tictactoe_game_check_winner(ttt_game_t *game)
*/
int tictactoe_game_make_turn(ttt_game_t *game, size_t x, size_t y)
{
if (game->board[x][y] != ' ') {
if (game->board[y][x] != ' ') {
pr_notice("position already occupied\n");
return -1;
}
game->board[x][y] = game->next_turn;
game->board[y][x] = game->next_turn;
game->winner = tictactoe_game_check_winner(game);
if (game->next_turn == 'X')