-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfillit.h
More file actions
executable file
·120 lines (106 loc) · 3.04 KB
/
fillit.h
File metadata and controls
executable file
·120 lines (106 loc) · 3.04 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: staeter <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/17 17:00:51 by staeter #+# #+# */
/* Updated: 2019/01/12 13:31:40 by nraziano ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FILLIT_H
# define FILLIT_H
# include <stdlib.h>
# include <unistd.h>
# include <fcntl.h>
# include "libft/includes/libft.h"
typedef char t_boolean;
/*
** 0 -- > y
** |
** v te->tab[x] & (1 << y) == value in (x,y)
** x
*/
typedef struct s_tetri
{
char letter;
unsigned short tab[16];
t_boolean ising;
} t_tetri;
/*
** tetri.c
*/
void free_tetri(t_tetri **te);
t_tetri *new_tetri(void);
t_boolean fill_tetri(t_tetri *te, char **str, char letter);
t_tetri *fillnew_tetri(char **str, char letter);
typedef struct s_node
{
t_tetri *te;
struct s_node *next;
} t_node;
/*
** node.c
*/
void free_node(t_node **n);
t_node *new_node(void);
t_boolean add_node(t_node **n, t_tetri *te);
void rm_node(t_node **n);
/*
** tetrilist.c
*/
t_node *get_tetrilist(const char *str);
short len_tetrilist(const t_node *n);
typedef struct s_grid
{
unsigned short gsize;
t_node *incr;
unsigned short tab[16];
unsigned short maxgap;
} t_grid;
/*
** grid.c
*/
void free_grid(t_grid **g);
t_grid *new_grid(unsigned short gsize);
t_boolean insertetri_grid(t_grid *g, t_tetri *te);
void rmtetri_grid(t_grid *g, t_tetri *te);
t_boolean incrtetri_grid(t_grid *g, t_tetri *te);
/*
** gaps.c
*/
t_boolean isvalidgap(const t_grid *g);
/*
** reader.c
*/
char *reader(int filedesc);
char *standi_reader(void);
char *file_reader(const char *filename);
/*
** check.c
*/
int isvalid_tetri(const t_tetri *te, unsigned short gsize);
t_tetri *getvalid_tetri(char **str, char letter);
/*
** move.c
*/
t_boolean move_tetri(t_tetri *te, int x, int y,
unsigned short gsize);
t_boolean isvalidxmove(t_tetri *te, int x, unsigned short gsize);
t_boolean isvalidymove(t_tetri *te, int y,
unsigned short gsize, int i);
void movetopleft_tetri(t_tetri *te, unsigned short gsize);
t_boolean movenextline_tetri(t_tetri *te, unsigned short gsize);
/*
** backtrack.c
*/
void backtrack(t_grid *g);
/*
** print.c
*/
t_boolean print_grid(const t_grid *g);
void print_tetri(const t_tetri *te);
void print_tetriing(const t_tetri *te, unsigned short gsize);
void print_tetrilist(const t_node *n, unsigned short gsize);
#endif