Compare commits
2 Commits
c1e61abb33
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5eb3a48045 | |||
| 6c8f751e2c |
9
drop4.c
9
drop4.c
@@ -11,11 +11,6 @@
|
|||||||
#define P1 1
|
#define P1 1
|
||||||
#define P2 2
|
#define P2 2
|
||||||
#define WIN_LENGTH 4
|
#define WIN_LENGTH 4
|
||||||
|
|
||||||
#define DIR_HORIZONTAL 0
|
|
||||||
#define DIR_VERTICAL 1
|
|
||||||
#define DIR_DIAG_DOWN 2
|
|
||||||
#define DIR_DIAG_UP 3
|
|
||||||
#define NUM_DIRECTIONS 4
|
#define NUM_DIRECTIONS 4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -95,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;
|
||||||
@@ -106,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