-
Notifications
You must be signed in to change notification settings - Fork 0
/
tetriminos_validate.c
52 lines (47 loc) · 1.41 KB
/
tetriminos_validate.c
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
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tetriminos_validate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: juazouz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/24 18:02:40 by juazouz #+# #+# */
/* Updated: 2018/11/28 15:46:05 by juazouz ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
static int count_adjacent(t_tetriminos *tetriminos, t_point *p1)
{
int i;
int dist;
t_point *p2;
int n;
i = 0;
n = 0;
while (i < TETRIMINOS_SIZE)
{
p2 = &tetriminos->points[i];
dist = distance(p1, p2);
if (dist == 1)
n++;
i++;
}
return (n);
}
int tetriminos_validate(t_tetriminos *tetriminos)
{
int i;
int tmp;
int n;
n = 0;
i = 0;
while (i < TETRIMINOS_SIZE)
{
tmp = count_adjacent(tetriminos, &tetriminos->points[i]);
if (tmp < 1)
return (0);
n += tmp;
i++;
}
return (n >= 6);
}