diff --git a/fillit.h b/fillit.h index 429050e..74f4c6a 100644 --- a/fillit.h +++ b/fillit.h @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */ -/* Updated: 2019/05/03 16:10:34 by hulamy ### ########.fr */ +/* Updated: 2019/05/03 20:57:59 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -52,5 +52,6 @@ void print_tetri(unsigned int bits, int size); //TO DELETE BEFORE EVAL void search_map(t_fillist *list); void print_map(unsigned int *tab, int width, int height, char letter); void print_final_map(t_fillist *list, int size); +void print_debug_map(t_fillist *list, int size, int position); #endif diff --git a/parse_input.c b/parse_input.c index 0e42162..03f4bf8 100644 --- a/parse_input.c +++ b/parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/05/03 16:10:12 by hulamy ### ########.fr */ +/* Updated: 2019/05/06 16:26:19 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,7 +62,6 @@ unsigned short reduce_tetri(unsigned short tetri, int width) void fill_list(char line[], t_fillist *list) { - unsigned int tmp; unsigned int mask; int i; @@ -90,6 +89,7 @@ void fill_list(char line[], t_fillist *list) list->height = i; // fabrique la ligne pour le tetriminos de la bonne largeur list->tetribit = reduce_tetri(list->tetribit, list->width); + list->position = -1; // DEBUG pour que print_final_map puisse imprimer correctement au fur et a mesure } /* diff --git a/print.c b/print.c index 01d56f7..595ba5d 100644 --- a/print.c +++ b/print.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */ -/* Updated: 2019/05/03 16:07:51 by hulamy ### ########.fr */ +/* Updated: 2019/05/06 16:27:51 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -107,7 +107,7 @@ void print_final_map(t_fillist *list, int size) { if (i && i % tmp->width == 0) j += size - tmp->width; - if (1 << (15 - i) & tmp->tetribit) + if (1 << (15 - i) & tmp->tetribit && tmp->position != -1) // DEBUG "&& tmp->position != -1" pour imprimer les bonnes lettres au coours du debug map[tmp->position + i + j - 1] = tmp->letter; } ft_putstr("position: "); ft_putnbrendl(tmp->position); // DEBUG @@ -125,4 +125,5 @@ void print_final_map(t_fillist *list, int size) ft_putchar(' '); } ft_putchar('\n'); + ft_putchar('\n'); // DEBUG } diff --git a/search_map.c b/search_map.c index 0eac674..a1a18b9 100644 --- a/search_map.c +++ b/search_map.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */ -/* Updated: 2019/05/03 16:05:23 by hulamy ### ########.fr */ +/* Updated: 2019/05/06 16:25:03 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -79,7 +79,7 @@ void add_remove(unsigned int *map, t_fillist *list, int size, int pos) ** function that recursively try to fill the map with the tetris */ -int fill_map(unsigned int *map, t_fillist *list, int size) +int fill_map(unsigned int *map, t_fillist *list, int size, t_fillist *link) { int pos; @@ -89,8 +89,12 @@ int fill_map(unsigned int *map, t_fillist *list, int size) while ((pos = find_place(map, list, size, pos))) { add_remove(map, list, size, pos); - if (fill_map(map, list->next, size)) - return (list->position = pos); + list->position = pos; + print_final_map(link, size); // DEBUG tente imprime la map avec des lettres + print_map(map, size, size, '#'); // DEBUG + ft_putchar('\n'); // DEBUG + if (fill_map(map, list->next, size, link)) + return (1); add_remove(map, list, size, pos); } return (0); @@ -136,7 +140,7 @@ void search_map(t_fillist *list) map = init_map(size); // lance la recursive fill_map en augmentant la taille de la map tant qu'il n'y a pas de solution - while (!fill_map(map, list, size)) + while (!fill_map(map, list, size, list)) map = init_map(size++); print_final_map(list, size); // DEBUG ft_putchar('\n'); // DEBUG