-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
45 lines (41 loc) · 947 Bytes
/
Copy pathutils.c
File metadata and controls
45 lines (41 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "utils.h"
bool is_even(int n)
{
return n % 2 == 0;
}
void get_possible_moves(int x, int y, board_t *board, point_t *possible_moves)
{
// UP RIGHT DOWN LEFT
if (y > 0 && is_free_cell(board, x, y - 1))
{
possible_moves[0] = create_point(x, y - 1);
}
else
{
possible_moves[0] = create_point(-1, -1);
}
if (x < board->width - 1 && is_free_cell(board, x + 1, y))
{
possible_moves[1] = create_point(x + 1, y);
}
else
{
possible_moves[1] = create_point(-1, -1);
}
if (y < board->height - 1 && is_free_cell(board, x, y + 1) )
{
possible_moves[2] = create_point(x, y + 1);
}
else
{
possible_moves[2] = create_point(-1, -1);
}
if (x > 0 && is_free_cell(board, x - 1, y))
{
possible_moves[3] = create_point(x - 1, y);
}
else
{
possible_moves[3] = create_point(-1, -1);
}
}