test add_remove qui ne fonctionne pas encore

This commit is contained in:
Hugo LAMY
2019-04-30 14:08:30 +02:00
parent ed1cde6e22
commit 2363e42167

View File

@@ -6,7 +6,7 @@
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */ /* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */ /* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */
/* Updated: 2019/04/30 13:25:42 by hulamy ### ########.fr */ /* Updated: 2019/04/30 14:07:47 by hulamy ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -56,38 +56,45 @@ int find_place(unsigned int *tab, t_fillist *list, int size)
** function that add or remove a tetri on the map ** function that add or remove a tetri on the map
*/ */
//void add_remove(unsigned int *map, t_fillist *list) void add_remove(unsigned int *map, t_fillist *list, int size, int pos)
//{ {
// unsigned int mask; unsigned int mask;
// unsigned int tmp; unsigned int tmp;
// int i; int j;
//
// mask = ~0u << (32 - list->width); mask = ~0u << (32 - list->width);
// tmp = 0; tmp = 0;
// /* j = list->height * size + pos;
// * trouver comment faire ;) // (void)map;
// */ // construit un tmp qui est une photo de la map de la taille du tetri a un emplacement donne
//} // ft_putnbrendl(pos);
while (j >= pos)
{
map[j / 32] |= ((mask >> (32 - j)) ^ map[j / 32]);
map[(j + size) / 32] |= ((mask << j) ^ map[(j + size) / 32]); // cette deuxieme ligne est la au cas ou on serait a cheval sur deux int du tab
j -= size;
}
}
/* /*
** function that recursively try to fill the map with the tetris ** 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)
//{ {
// if (!list) if (!list)
// return (1); return (1);
// while (find_place(map, list, size)) while (find_place(map, list, size))
// { {
// add_remove(map, list, size); add_remove(map, list, size, list->position);
// print_map(map, size, size); print_map(map, size, size);
// if (fill_map(map, size, list->next) if (fill_map(map, list->next, size))
// return (1); return (1);
// add_remove(map, list, size); add_remove(map, list, size, list->position);
// list->position++; list->position++;
// } }
// return (0); return (0);
//} }
/* /*
** function that init the map to the right size fill with int equal to zeros ** function that init the map to the right size fill with int equal to zeros
@@ -155,6 +162,12 @@ void search_map(t_fillist *list)
while (size * size < i * 4) while (size * size < i * 4)
size++; size++;
map = init_map(size); map = init_map(size);
// en cours de test :
// quand add_remove_marchera la ligne d'apres imprimera la map avec les pixels du tetri rajoutes a la bonne place
add_remove(tab, list, 10, find_place(tab, list, 10));
print_map(tab, 10, 10);
// lance la recursive fill_map en augmentant la taille de la map tant qu'il n'y a pas de solution // lance la recursive fill_map en augmentant la taille de la map tant qu'il n'y a pas de solution
// ft_putstr("test "); // ft_putstr("test ");
// ft_putnbrendl(size); // ft_putnbrendl(size);