From 39a59058baa4d7aacad260dc87a923a980dd913f Mon Sep 17 00:00:00 2001 From: Manzovince Date: Tue, 23 Apr 2019 21:44:11 +0200 Subject: [PATCH] Few edit + BUG on bit convertion for tetri starting at top left corner --- .gitignore | 2 ++ add_to_list.c | 25 +++++++++++++------------ get_smallest_square.c | 6 ++---- main.c | 2 +- parse_input.c | 18 ++++++++---------- samples/1tetri | 8 ++++---- 6 files changed, 30 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index a5cf236..9b97ae7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ a\.out *.swp fillit + +test_fillit\.c diff --git a/add_to_list.c b/add_to_list.c index fd7d130..0a18586 100644 --- a/add_to_list.c +++ b/add_to_list.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */ -/* Updated: 2019/04/23 21:04:43 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/23 21:36:37 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,13 +30,13 @@ void print_bits(short line) } /* -** this function transforme a tetrminos char* into a short of 16 bites +** Function that transforme a tetrminos char* into a short of 16 bites ** then it fills it and its reverse into the list */ int fill_list(char line[], t_fillist *list) { - short tmp; +// short tmp; int i; i = 0; @@ -48,14 +48,15 @@ int fill_list(char line[], t_fillist *list) if (line[i++] == '#') list->tetribit |= 1; } - tmp = list->tetribit; - while (tmp) - { - if (tmp & 1) - list->tibirtet |= 1; - list->tibirtet <<= 1; - tmp >>= 1; - } +// tmp = list->tetribit; +// while (tmp) +// { +// if (tmp & 1) +// list->tibirtet |= 1; +// list->tibirtet <<= 1; +// tmp >>= 1; +// } + print_bits(list->tetribit); return (0); } @@ -98,7 +99,7 @@ void print_test(int octet) /* ** DELETE BEFORE EVAL - TEST FUNCTION -** Test +** Test for big map */ void test(unsigned int map[]) diff --git a/get_smallest_square.c b/get_smallest_square.c index 399d74e..4a4c8d2 100644 --- a/get_smallest_square.c +++ b/get_smallest_square.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/12 22:29:45 by vmanzoni #+# #+# */ -/* Updated: 2019/04/23 21:03:10 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/23 21:42:35 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,11 +19,9 @@ unsigned int *initialize_map(int size) { unsigned int *map[0]; - int i; - i = size; while (size--) - map[i] = malloc(sizeof(unsigned int) * i); + map[size] = 0; return (map); } diff --git a/main.c b/main.c index 77afdd6..2448ba8 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/04/23 16:19:17 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/23 21:39:42 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/parse_input.c b/parse_input.c index f5f88cc..49ce03e 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/04/23 21:09:40 by vmanzoni ### ########.fr */ +/* Updated: 2019/04/23 21:23:47 by vmanzoni ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,15 +38,13 @@ void parse_input(char *input) while (input[i] && input[i] != '.' && input[i] != '#') i++; } - /*DEBUG PART - Print each tetribit*/ -/* - while (list != NULL) - { - printf("%i\n", list->tetribit); - printf("\n"); - list = list->next; - } -*/ +/*DEBUG PART - Print each tetribit*/ +// while (list != NULL) +// { +// printf("%i\n", list->tetribit); +// printf("\n"); +// list = list->next; +// } } /* diff --git a/samples/1tetri b/samples/1tetri index 3f1734a..caa819e 100644 --- a/samples/1tetri +++ b/samples/1tetri @@ -1,4 +1,4 @@ -...# -...# -...# -...# +#... +#... +#... +#...