fix: check victory earlier and remove the other check
This commit is contained in:
4
drop4.c
4
drop4.c
@@ -90,6 +90,8 @@ int is_winning_move(Game *game) {
|
|||||||
break;
|
break;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
if (count >= WIN_LENGTH)
|
||||||
|
return 1;
|
||||||
for (int offset = 1; offset < WIN_LENGTH; offset++) {
|
for (int offset = 1; offset < WIN_LENGTH; offset++) {
|
||||||
int new_row = row - directions[dir][0] * offset;
|
int new_row = row - directions[dir][0] * offset;
|
||||||
int new_col = col - directions[dir][1] * offset;
|
int new_col = col - directions[dir][1] * offset;
|
||||||
@@ -101,8 +103,6 @@ int is_winning_move(Game *game) {
|
|||||||
if (count >= WIN_LENGTH)
|
if (count >= WIN_LENGTH)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (count >= WIN_LENGTH)
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user