From 1811268725402de871633eac7282c7aa2b599ac7 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Mon, 20 May 2019 15:58:45 +0200 Subject: [PATCH 1/5] fillit ultrrrrrrra rapide ! pas encore a la norme --- main.c | 7 +++- parse_input.c | 3 +- samples/map_slack | 99 +++++++++++++++++++++++++++++++++++++++++++++++ search_map.c | 4 +- 4 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 samples/map_slack diff --git a/main.c b/main.c index 8d39b57..9afa677 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/05/17 18:40:34 by hulamy ### ########.fr */ +/* Updated: 2019/05/20 15:51:50 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -29,8 +29,11 @@ int main(int argc, char **argv) // print_error("error: Invalid file.\n"); // print_error_extended(check_file_errors(input)); size = parse_input(input, &list); - ft_putnbrendl(size); + ft_putchar('\n'); + ft_putendl("result for humans :"); print_final_map(list, size, 1); // DEBUG + ft_putchar('\n'); + ft_putendl("result for moulinette :"); print_final_map(list, size, 0); // DEBUG } else diff --git a/parse_input.c b/parse_input.c index 933983b..892750b 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/18 14:17:14 by hulamy ### ########.fr */ +/* Updated: 2019/05/20 15:43:57 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -91,6 +91,7 @@ void fill_list(char line[], t_fillist *list) i++; list->height = i; list->tetribit = reduce_tetri(list->tetribit, list->width); + list->same = NULL; list->test = 0; // DEBUG pour que print_final_map puisse imprimer correctement au fur et a mesure } diff --git a/samples/map_slack b/samples/map_slack new file mode 100644 index 0000000..6f6a1e5 --- /dev/null +++ b/samples/map_slack @@ -0,0 +1,99 @@ +...# +...# +..## +.... + +#... +###. +.... +.... + +.#.. +.#.. +##.. +.... + +...# +...# +..## +.... + +...# +...# +..## +.... + +#... +###. +.... +.... + +.#.. +.#.. +##.. +.... + +...# +...# +..## +.... + +...# +...# +..## +.... + +#... +###. +.... +.... + +.#.. +.#.. +##.. +.... + +...# +...# +..## +.... + +...# +...# +..## +.... + +#... +###. +.... +.... + +.#.. +.#.. +##.. +.... + +...# +...# +..## +.... + +...# +...# +..## +.... + +#... +###. +.... +.... + +.#.. +.#.. +##.. +.... + +...# +...# +..## +.... diff --git a/search_map.c b/search_map.c index eb0cfba..fb36681 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/20 15:41:59 by hulamy ### ########.fr */ +/* Updated: 2019/05/20 15:50:12 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -279,7 +279,6 @@ int check_same_tetri(t_fillist *list, int num) curr_tetri = list; while (curr_tetri != NULL) { - curr_tetri->same = NULL; i = 0; if (!(curr_tetri->memory = (unsigned int *)malloc(sizeof(*curr_tetri->memory) * num))) return (0); @@ -342,6 +341,7 @@ int search_map(t_fillist *list) map[num--] = 0; i = fill_map(map, list, size++); } + ft_putendl("result in binary :"); print_map(map, size - 1, size - 1, '#'); // DEBUG return (--size); } From 1a16e305d381c54df49bf9327c30fd7e2982fe7a Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Tue, 21 May 2019 15:31:04 +0200 Subject: [PATCH 2/5] a une ligne pret le programme fonctionne tout le temps aaaarg --- samples/jdugoudr | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ search_map.c | 16 ++++++++- 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 samples/jdugoudr diff --git a/samples/jdugoudr b/samples/jdugoudr new file mode 100644 index 0000000..b1d432f --- /dev/null +++ b/samples/jdugoudr @@ -0,0 +1,89 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/search_map.c b/search_map.c index fb36681..6acebf1 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/20 15:50:12 by hulamy ### ########.fr */ +/* Updated: 2019/05/21 15:27:37 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -231,6 +231,19 @@ int check_tetri_memory(t_fillist *list, int pos) return (0); } +void remove_tetri_memory(t_fillist *list, int pos) +{ + t_fillist *tetri; + unsigned int mask; + + tetri = list; + mask = 1 << ((pos % 32) - 1); + if (tetri->same != NULL) + tetri->same->memory[pos / 32] ^= mask; + else + tetri->memory[pos / 32] ^= mask; +} + /* ** Function that recursively try to fill the map with the tetris */ @@ -247,6 +260,7 @@ int fill_map(unsigned int *map, t_fillist *list, int size) if (fill_map(map, list->next, size)) return (1); add_remove(map, list, size); +// remove_tetri_memory(list, list->position); } return (0); } From 6b9936b0cd45aad3d64c4de96160d2239e3dae0f Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Fri, 24 May 2019 18:05:18 +0200 Subject: [PATCH 3/5] en cours de reorganisation des fichiers pour gerer les flags --- .DS_Store | Bin 6148 -> 8196 bytes f_bonus.c | 103 ++++++ handle_errors.c => f_handle_errors.c | 24 +- parse_input.c => f_parse_input.c | 4 +- print.c => f_print.c | 4 +- ...with_colors.c => f_print_map_with_colors.c | 0 read_file.c => f_read_file.c | 0 f_search_map.c | 293 ++++++++++++++++++ fillit.h | 32 +- main.c | 97 +++++- samples/{ => debug}/jdugoudr | 0 samples/debug/jdugoudr1 | 84 +++++ samples/debug/jdugoudr10 | 84 +++++ samples/debug/jdugoudr11 | 84 +++++ samples/debug/jdugoudr12 | 84 +++++ samples/debug/jdugoudr13 | 84 +++++ samples/debug/jdugoudr14 | 84 +++++ samples/debug/jdugoudr15 | 84 +++++ samples/debug/jdugoudr16 | 84 +++++ samples/debug/jdugoudr17 | 84 +++++ samples/debug/jdugoudr18 | 79 +++++ samples/debug/jdugoudr18_17 | 79 +++++ samples/debug/jdugoudr18_17_16 | 74 +++++ samples/debug/jdugoudr18_17_16_15 | 69 +++++ samples/debug/jdugoudr18_17_16_15_14 | 64 ++++ samples/debug/jdugoudr18_17_16_15_14_13 | 59 ++++ samples/debug/jdugoudr18_17_16_15_14_13_12 | 54 ++++ samples/debug/jdugoudr18_17_16_15_14_13_12_11 | 49 +++ .../debug/jdugoudr18_17_16_15_14_13_12_11_10 | 44 +++ samples/debug/jdugoudr1_10 | 79 +++++ samples/debug/jdugoudr1_11 | 79 +++++ samples/debug/jdugoudr1_12 | 79 +++++ samples/debug/jdugoudr1_13 | 79 +++++ samples/debug/jdugoudr1_14 | 79 +++++ samples/debug/jdugoudr1_15 | 79 +++++ samples/debug/jdugoudr1_16 | 79 +++++ samples/debug/jdugoudr1_17 | 79 +++++ samples/debug/jdugoudr1_18 | 79 +++++ samples/debug/jdugoudr1_2 | 79 +++++ samples/debug/jdugoudr1_2_3 | 74 +++++ samples/debug/jdugoudr1_2_3_4 | 69 +++++ samples/debug/jdugoudr1_2_3_4_5 | 64 ++++ samples/debug/jdugoudr1_2_3_4_5_6 | 59 ++++ samples/debug/jdugoudr1_2_3_4_5_6_7 | 54 ++++ samples/debug/jdugoudr1_2_3_4_5_6_7_8 | 49 +++ samples/debug/jdugoudr1_2_3_4_5_6_7_8_9 | 44 +++ samples/debug/jdugoudr1_2_3_4_5_6_7_8_9_10 | 39 +++ samples/debug/jdugoudr1_3 | 79 +++++ samples/debug/jdugoudr1_4 | 79 +++++ samples/debug/jdugoudr1_5 | 79 +++++ samples/debug/jdugoudr1_6 | 79 +++++ samples/debug/jdugoudr1_7 | 79 +++++ samples/debug/jdugoudr1_8 | 79 +++++ samples/debug/jdugoudr1_9 | 79 +++++ samples/debug/jdugoudr2 | 84 +++++ samples/debug/jdugoudr3 | 84 +++++ samples/debug/jdugoudr4 | 84 +++++ samples/debug/jdugoudr5 | 84 +++++ samples/debug/jdugoudr6 | 84 +++++ samples/debug/jdugoudr7 | 84 +++++ samples/debug/jdugoudr8 | 84 +++++ samples/debug/jdugoudr9 | 84 +++++ search_map.c => test_search_map2.c | 51 ++- testmap | Bin 13908 -> 0 bytes 64 files changed, 4351 insertions(+), 51 deletions(-) create mode 100644 f_bonus.c rename handle_errors.c => f_handle_errors.c (88%) rename parse_input.c => f_parse_input.c (97%) rename print.c => f_print.c (92%) rename print_map_with_colors.c => f_print_map_with_colors.c (100%) rename read_file.c => f_read_file.c (100%) create mode 100644 f_search_map.c rename samples/{ => debug}/jdugoudr (100%) create mode 100644 samples/debug/jdugoudr1 create mode 100644 samples/debug/jdugoudr10 create mode 100644 samples/debug/jdugoudr11 create mode 100644 samples/debug/jdugoudr12 create mode 100644 samples/debug/jdugoudr13 create mode 100644 samples/debug/jdugoudr14 create mode 100644 samples/debug/jdugoudr15 create mode 100644 samples/debug/jdugoudr16 create mode 100644 samples/debug/jdugoudr17 create mode 100644 samples/debug/jdugoudr18 create mode 100644 samples/debug/jdugoudr18_17 create mode 100644 samples/debug/jdugoudr18_17_16 create mode 100644 samples/debug/jdugoudr18_17_16_15 create mode 100644 samples/debug/jdugoudr18_17_16_15_14 create mode 100644 samples/debug/jdugoudr18_17_16_15_14_13 create mode 100644 samples/debug/jdugoudr18_17_16_15_14_13_12 create mode 100644 samples/debug/jdugoudr18_17_16_15_14_13_12_11 create mode 100644 samples/debug/jdugoudr18_17_16_15_14_13_12_11_10 create mode 100644 samples/debug/jdugoudr1_10 create mode 100644 samples/debug/jdugoudr1_11 create mode 100644 samples/debug/jdugoudr1_12 create mode 100644 samples/debug/jdugoudr1_13 create mode 100644 samples/debug/jdugoudr1_14 create mode 100644 samples/debug/jdugoudr1_15 create mode 100644 samples/debug/jdugoudr1_16 create mode 100644 samples/debug/jdugoudr1_17 create mode 100644 samples/debug/jdugoudr1_18 create mode 100644 samples/debug/jdugoudr1_2 create mode 100644 samples/debug/jdugoudr1_2_3 create mode 100644 samples/debug/jdugoudr1_2_3_4 create mode 100644 samples/debug/jdugoudr1_2_3_4_5 create mode 100644 samples/debug/jdugoudr1_2_3_4_5_6 create mode 100644 samples/debug/jdugoudr1_2_3_4_5_6_7 create mode 100644 samples/debug/jdugoudr1_2_3_4_5_6_7_8 create mode 100644 samples/debug/jdugoudr1_2_3_4_5_6_7_8_9 create mode 100644 samples/debug/jdugoudr1_2_3_4_5_6_7_8_9_10 create mode 100644 samples/debug/jdugoudr1_3 create mode 100644 samples/debug/jdugoudr1_4 create mode 100644 samples/debug/jdugoudr1_5 create mode 100644 samples/debug/jdugoudr1_6 create mode 100644 samples/debug/jdugoudr1_7 create mode 100644 samples/debug/jdugoudr1_8 create mode 100644 samples/debug/jdugoudr1_9 create mode 100644 samples/debug/jdugoudr2 create mode 100644 samples/debug/jdugoudr3 create mode 100644 samples/debug/jdugoudr4 create mode 100644 samples/debug/jdugoudr5 create mode 100644 samples/debug/jdugoudr6 create mode 100644 samples/debug/jdugoudr7 create mode 100644 samples/debug/jdugoudr8 create mode 100644 samples/debug/jdugoudr9 rename search_map.c => test_search_map2.c (88%) delete mode 100755 testmap diff --git a/.DS_Store b/.DS_Store index 6c438ddf1a8404debe87bea631fd2e49de06cf1d..5c5092dfca15558b80701859ce4b6d88133165e3 100644 GIT binary patch literal 8196 zcmeHMU2GIp6h7a!rL!{7X{`dv{SVRmQPncY@G zViBV;>63pk@quVGMtM<#k3jT^=##ODg3$*hCcdCPAPFYwxpSv=ciZBdfiO3@_uRSX zoO|y5`rSEur$mI#oY6+Kl86+pLTXF7S)d5LsPjrB7^z|j_9uI+tuN`MGV?6Mfe?WZ zfe?WZfe?WZf!hTE&e@_Ui{yQ&4cicb5P`cA0r7r_aTPKi$SEoPR|hx#6@XXoR=i}_QuJJ{zP+rDaTk;ml-ekCeYt2 z94pDC1f?iLHksrWMWx!w1uWcr*Qo7`^803HG-F$?*V=jok+SlNC6!9_o~7zCeb3%~ z`_%(OR?jrGy!Ox4O&4?I|>>x-EV%iYg80JMyx?s4;#F?{f;4` z7}}=_&%@E18g%_Bq3Oz++!}$yx@KMNcNrNi5g4{?RMq}tR@%^9u>^MAv{}^$?8K;P zYerPYY2T*mgL%1SZErBRy;jwS_@hvYx9A3A9i6&T=GtEo7Bx3W{cJPvh zg|5Re#DbK@_{o@$USoW%M6po{A|I8gCUS>P4^um5seU?24xOTDIz#8^JYAqK=xh3c zuF^I7gZ`wy=x-3BsKP2Vpc(720WH{yZtTEL?7|ax8b>gKairiNgX1`X=Wq(o<20u6 z3SPtOcmrqfK0d&QIE!;Qj|;enOZWztaRuMuDz4#I{D$9gGg1~&Bh`@_x!y>Sy2w8S zvwL7p*K)t~Ot|?>!1%WoW_;bwUAy)mBN@@L2-D-syrz!GrP2D<$&x987 zAJz4BEm3B^RwlJ=>L!Ibu2o3w7PURfr$8&0+DFyx3X@%1BDK2O5shjjAJ)|ML=_GH zP2pP-_$#_XztDBM$;7R|GSr|RYtf1=i2J17gT2^~gBZjx4&g9N9A)}iI0g?nOkk2J zd>Sv{MZAQUnZmF76n+zL;~l(<_n68b;bVLOx#NGEVX+;k|aZ^Iv zf;4gcMw4$p&tfiFEMifVG9vz~vt*8ZUp8$!=`pbgt`+2oM8a)JGV$XVXbV>N^D1%d zihK*w*aF(3Rr#)WdQ&Dhuu|Ordlvuxf2VIVTz`l_h`=onKzVmxcPAUn{y-_UjqpH> z>oZ(M5q48j`YzlE6EW^z$63z(!;t&2Ko<|>l$5OD^1puw5Wk+o{EsmI-`)BD9|!AN A;Q#;t delta 120 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUE#6q~50$jGxXU^gQp&tx8fC6lAY!Z%+K zGiTgbaFTg3I|qj#Gf*WE2yg=lSCFQSiQkzg^UFAbOl4qXU|<2!Ob}ziVw>Z6<}d>Q D5RVgl diff --git a/f_bonus.c b/f_bonus.c new file mode 100644 index 0000000..5b4143d --- /dev/null +++ b/f_bonus.c @@ -0,0 +1,103 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* bonus.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/05/24 14:42:46 by hulamy #+# #+# */ +/* Updated: 2019/05/24 14:46:08 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "fillit.h" + +/* +** Test optimisation for not testing wrong maps when tetri are identical +*/ + +int check_tetri_memory(t_fillist *list, int pos) +{ + t_fillist *tetri; + unsigned int mask; + + tetri = list; + mask = 1 << ((pos % 32) - 1); + if (tetri->same) + { + if (!(tetri->same->memory[pos / 32] & mask)) + return (tetri->same->memory[pos / 32] |= mask); + } + else + { +// if (!(tetri->memory[pos / 32] & mask)) + return (tetri->memory[pos / 32] |= mask); + } + return (0); +} + +void remove_tetri_memory(t_fillist *list, int pos) +{ + t_fillist *tetri; + unsigned int mask; + + tetri = list; + mask = 1 << ((pos % 32) - 1); + if (tetri->same != NULL) + { + if ((tetri->same->memory[pos / 32] & mask)) + tetri->same->memory[pos / 32] ^= mask; + } + else + { + if ((tetri->memory[pos / 32] & mask)) + tetri->memory[pos / 32] ^= mask; + } +} + +/* +** Test optimisation for not testing wrong maps when tetri are identical +*/ + +int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b) +{ + if (tetri_a->tetribit != tetri_b->tetribit) + return (0); + if (tetri_a->width != tetri_b->width) + return (0); + if (tetri_a->height != tetri_b->height) + return (0); + return (1); +} + +/* +** Test optimisation for not testing wrong maps when tetri are identical +*/ + +int check_same_tetri(t_fillist *list, int num) +{ + t_fillist *curr_tetri; + t_fillist *next_tetri; + int i; + + curr_tetri = list; + while (curr_tetri != NULL) + { + i = 0; + if (!(curr_tetri->memory = (unsigned int *)malloc(sizeof(*curr_tetri->memory) * num))) + return (0); + while (i < num) + curr_tetri->memory[i++] = 0; + next_tetri = curr_tetri->next; + while (next_tetri != NULL) + { + if (compare_tetri(curr_tetri, next_tetri)) + if (next_tetri->same == NULL) + next_tetri->same = curr_tetri; + next_tetri = next_tetri->next; + } + curr_tetri = curr_tetri->next; + } + return (0); +} + diff --git a/handle_errors.c b/f_handle_errors.c similarity index 88% rename from handle_errors.c rename to f_handle_errors.c index 6ff8593..230cc2a 100644 --- a/handle_errors.c +++ b/f_handle_errors.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */ -/* Updated: 2019/05/09 12:45:25 by vmanzoni ### ########.fr */ +/* Updated: 2019/05/24 18:02:08 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ void print_error(char *str) { write(1, str, ft_strlen(str)); - exit(1); +// exit(1); } /* @@ -28,8 +28,13 @@ void print_error(char *str) ** and exit program */ -void print_error_extended(int error) +void print_error_extended(int error, int *dope) { + if (!dope[3]) + { + print_error("error\n"); + exit(0); + } if (error == 1) ft_putstr("error: File contains char other than '.','#' and '\\n'.\n"); if (error == 2) @@ -41,7 +46,7 @@ void print_error_extended(int error) ft_putstr("error: Tetrimino has more or less than 4 #.\n"); if (error == 5) ft_putstr("error: Tetrimino # are not all connected.\n"); - exit(1); +// exit(1); } /* @@ -51,7 +56,7 @@ void print_error_extended(int error) ** - two \n in a row */ -int check_file_errors(char *file) +void check_file_errors(char *file, int *dope) { int i; int line_nbr; @@ -61,19 +66,18 @@ int check_file_errors(char *file) while (file[i]) { if (file[i] != '.' && file[i] != '#' && file[i] != '\n') - return (1); + print_error_extended(1, dope); else if (file[i] == '\n') line_nbr++; if (file[i] == '\n' && line_nbr % 5 == 0 && file[i-1] != '\n') - print_error("error\n"); + print_error("error\n"); // est-ce que ca n'imprime pas error deux fois ?? if (file[i] == '\n' && file[i+1] != '\0' && \ file[i+2] != '.' && file[i+2] != '#') - return (2); + print_error_extended(2, dope); i++; } if (line_nbr < 4 || line_nbr > 129) - return (3); - return (0); + print_error_extended(3, dope); } /* diff --git a/parse_input.c b/f_parse_input.c similarity index 97% rename from parse_input.c rename to f_parse_input.c index 892750b..79c2fc6 100644 --- a/parse_input.c +++ b/f_parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/05/20 15:43:57 by hulamy ### ########.fr */ +/* Updated: 2019/05/24 18:04:46 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -126,7 +126,7 @@ int add_to_list(char *line, t_fillist **list, char letter) ** Function that parse a file and put each tetrimino in a linked list */ -int parse_input(char *input, t_fillist **list) +int parse_input(char *input, t_fillist **list, int *dope) { char tetri[20]; int i; diff --git a/print.c b/f_print.c similarity index 92% rename from print.c rename to f_print.c index 7131c05..bfc4f54 100644 --- a/print.c +++ b/f_print.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */ -/* Updated: 2019/05/17 17:24:54 by hulamy ### ########.fr */ +/* Updated: 2019/05/22 14:34:45 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -82,7 +82,7 @@ void print_final_map(t_fillist *list, int size, int flag) // DEBUG flag vaut 0 p { if (i && i % tmp->width == 0) j += size - tmp->width; - if (1 << (15 - i) & tmp->tetribit/* && tmp->test == 1*/) // DEBUG "&& tmp->position != -1" pour imprimer les bonnes lettres au coours du debug + if (1 << (15 - i) & tmp->tetribit && tmp->test == 1) // DEBUG "&& tmp->test == 1" pour imprimer les bonnes lettres au coours du debug map[tmp->position + i + j - 1] = tmp->letter; } tmp = tmp->next; diff --git a/print_map_with_colors.c b/f_print_map_with_colors.c similarity index 100% rename from print_map_with_colors.c rename to f_print_map_with_colors.c diff --git a/read_file.c b/f_read_file.c similarity index 100% rename from read_file.c rename to f_read_file.c diff --git a/f_search_map.c b/f_search_map.c new file mode 100644 index 0000000..03d6628 --- /dev/null +++ b/f_search_map.c @@ -0,0 +1,293 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* search_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */ +/* Updated: 2019/05/24 14:48:33 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "fillit.h" + +/* +** OLD VERSION of find_place and fit_in_place all in one but with a lot of divisions and modulo +** +** int find_place(unsigned int *tab, t_fillist *list, int size, int pos) +** { +** int i; +** int j; +** unsigned int mask; +** unsigned int tmp; +** +** mask = ~0u << (32 - list->width); +** tmp = mask; +** i = pos; +** while (i < (size - list->height + 1) * size) +** { +** if (i % size == size - list->width + 1) +** i += list->width - 1; +** else +** { +** tmp = 0; +** j = (list->height - 1) * size + i; +** while (j >= i) +** { +** tmp >>= list->width; +** tmp |= (mask & (tab[j / 32] << j)); +** tmp |= (mask & (tab[(j + list->width) / 32] >> (32 - j))); +** j -= size; +** } +** if (!((tmp >> 16) & list->tetribit)) +** return (i + 1); +** i++; +** } +** } +** return (0); +** } +*/ + +/* +** function that try to optimize the speed +** SECOND ATTEMPT +** by finding the isolated dots whille fillling the map +** untill they get more numerous than the max amount available +** TOTAL FAILURE :p +** +** int check_others(unsigned int *map, t_fillist *list, int size, int num) +** { +** t_fillist *tmp; +** int dots; +** int total; +** int i; +** int j; +** +** dots = 0; +** i = -1; +** num *= 4; +** total = size * size; +** while (++i < total && dots <= total - num) +** { +** tmp = list->next; +** j = 1; +** // saute les position pas vides +** while (1 << (i % 32) & map[i % 32]) +** i++; +** // pour chaque position vide regarde si chaque tetri non encode places peuvent y rentrer +** while (j && tmp) +** { +** // si le tetri est trop a droite ou trop en bas il ne rentre pas ce n'est pas la peine de chercher donc on passe au tetri suivant +** if (tmp->width > (size - i % size) || (total - i) <= (tmp->height * size)) +** tmp = tmp->next; +** // sinon verifier si on peut le mettre a cette position et si on ne peut pas passer au tetri suivant +** else if (!fit_in_place(map, list, size, i)) +** tmp = tmp->next; +** // si le tetri peut rentrer on arrete la boucle en mettant j = 0 +** else +** j = 0; +** } +** // si j existe c que le tetri ne pouvait pas etre place donc on rajoute 1 au compteur de point isoles +** if (j) +** dots++; +** } +** return (dots > total - num); +** } +*/ + +/* +** function that try to optimize the speed +** FIRST ATTEMPT +** by verifying if the place left is enough to place at least +** one of each tetri left +** TOTAL FAILURE :p +** +** int check_others(unsigned int *map, t_fillist *list, int size, int num) +** { +** t_fillist *tmp; +** +** // verifie que les tetri restant puissent un par un se placer sur la map +** // ca n'optimise qu'en fin de map donc ca ralentit les grosses map en fait +** while ((tmp = tmp->next)) +** if (!find_place(map, tmp, size, 0)) +** return (0); +** return (1); +** } +*/ + +/* +** function that look if a tretri fit in a place +*/ + +unsigned int fit_in_place(unsigned int *map, t_fillist *lst, int size, int i) +{ + unsigned int tmp; + unsigned int mask; + unsigned int tetri; + int n; + int r; + + n = lst->num; + r = lst->rank; + i = lst->height; + tetri = lst->tetribit << 16 >> lst->width; + tmp = 0; + mask = ~0u << (32 - lst->width); + while (i--) + { + if (tmp & tetri) + return (0); + if (r >= 32 && ++n) + r -= 32; + tmp = (mask & (map[n] << r)) | (mask & (map[n + 1] >> (32 - r))); + tetri <<= lst->width; + r += size; + } + return (!(tmp & tetri)); +} + +/* +** function that look for the first place in the map for a tetri +*/ + +int find_place(unsigned int *map, t_fillist *list, int size) +{ + int limit; + int pos; + + pos = list->position; + list->place = pos % size; + list->rank = pos % 32; + list->num = pos / 32; + limit = (size - list->height + 1) * size; + while (pos < limit) + { + if (list->rank >= 32 && ++list->num) + list->rank -= 32; + if (list->place > size - list->width) + { + list->place = -1; + pos += list->width - 2; + list->rank += list->width - 2; + } + else if (fit_in_place(map, list, size, 0)) + return ((list->position = pos + 1)); + pos++; + list->place++; + list->rank++; + } + return (0); +} + +/* +** function that add or remove a tetri on the map +*/ + +void add_remove(unsigned int *map, t_fillist *list, int size) +{ + unsigned int mask; + unsigned short tetri; + int i; + int j; + + tetri = list->tetribit; + mask = ~0u << (32 - list->width); + i = (list->height - 1) * list->width; + j = (list->height - 1) * size + list->position; + while (j >= list->position) + { + map[(j - 1) / 32] ^= (mask & tetri << (16 + i)) >> (j - 1); + map[(j - 1) / 32 + 1] ^= (mask & tetri << (16 + i)) << (32 - j) << 1; + j -= size; + i -= list->width; + } +} + +/* +** Function that recursively try to fill the map with the tetris +*/ + +int fill_map(unsigned int *map, t_fillist *list, int size, t_fillist *link) +{ + if (!list) + return (1); + list->position = 0; + while (find_place(map, list, size)) + { + add_remove(map, list, size); + + list->test = 1; // DEBUG +// print_final_map(link, size, 1); // DEBUG +// ft_putchar('\n'); // DEBUG + + if (check_tetri_memory(list, list->position)) + if (fill_map(map, list->next, size, link)) + return (1); + add_remove(map, list, size); +// remove_tetri_memory(list, list->position); + + list->test = 0; // DEBUG + + } + return (0); +} + +/* +** function that send to "fill_map" a map of a certain size and increment its size untill it's solved +*/ + +int search_map(t_fillist *list) +{ + t_fillist *tmp; + unsigned int *map; + int size; + int num; + int i; + + /////////////////////////////////////////////////// TEST + unsigned int print; + tmp = list; + while (tmp) + { + // imression pour tests + check_same_tetri(list, 1); + print = tmp->tetribit; + print <<= 16; + print_map(&print, tmp->width, tmp->height, tmp->letter); + if (tmp->same) + { + print = tmp->same->tetribit; + print <<= 16; + ft_putstr("same --> "); + ft_putchar(tmp->same->letter); + ft_putchar('\n'); + } + ft_putchar('\n'); + tmp = tmp->next; + } + /////////////////////////////////////////////////// TEST + + size = 2; + num = 1; + tmp = list; + while ((tmp = tmp->next)) + num++; + while (size * size < num * 4) + size++; + i = 0; + while (!i) + { + ft_putnbrendl(size); + num = (size * size) / 32 + 1; + if (!(map = (unsigned int *)malloc(sizeof(*map) * num))) + return (0); + check_same_tetri(list, num); + while (num) + map[num--] = 0; + i = fill_map(map, list, size++, list); + } + ft_putendl("result in binary :"); // DEBUG (pas dans le main car besoin de map) + print_map(map, size - 1, size - 1, '#'); // DEBUG + return (--size); +} diff --git a/fillit.h b/fillit.h index 15b7219..05b191d 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/20 15:18:43 by hulamy ### ########.fr */ +/* Updated: 2019/05/24 18:04:17 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,7 +46,6 @@ /* ** STRUCTURE */ - typedef struct s_fillist { unsigned short tetribit; @@ -64,23 +63,44 @@ typedef struct s_fillist } t_fillist; /* -** FUNCTIONS +** main.c */ +int main(int argc, char **argv); +int *create_dope(char *av); +int is_mdp(int ac, char **av); +/* +** read_file.c +*/ char *read_file(char *file); + +/* +** handle_errors.c +*/ void print_error(char *s); -void print_error_extended(int error); -int parse_input(char *input, t_fillist **list); -int check_file_errors(char *file); +void print_error_extended(int error, int *dope); +int check_file_errors(char *file, int *dope); int check_tetri_errors(char *tetri); int check_tetri_errors_proxy(char *tetri); + +/* +** handle_errors.c +*/ +int parse_input(char *input, t_fillist **list, int *dope); int add_to_list(char *square, t_fillist **list, char letter); void fill_list(char line[], t_fillist *list); +unsigned short reduce_tetri(unsigned short tetri, int width); +unsigned short tab_to_bin(char line[]); + void print_bits(unsigned int bits, int size); //TO DELETE BEFORE EVAL void print_tetri(unsigned int bits, int size); //TO DELETE BEFORE EVAL int 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, int flag); void ft_put_tetri_color(char c); +int check_tetri_memory(t_fillist *list, int pos); +void remove_tetri_memory(t_fillist *list, int pos); +int check_same_tetri(t_fillist *list, int num); +int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b); #endif diff --git a/main.c b/main.c index 9afa677..39d35f9 100644 --- a/main.c +++ b/main.c @@ -6,35 +6,100 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/05/20 15:51:50 by hulamy ### ########.fr */ +/* Updated: 2019/05/24 18:02:29 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" -int main(int argc, char **argv) +/* +** function that put the flags for bonus into a tab of int +** +** d : debug print (print the map during the backtracking) +** o : optimisation ultra fast but with some errors still +** p : print extended (print the tetri and the map in different formats) +** e : error extended (error message more precise AND no error for too much tetri) +*/ + +int *create_dope(char *av) +{ + char *comp; + int *dope; + int i; + int j; + + comp = "dope"; + if (!(dope = (int*)malloc(sizeof(*dope) * 4))) + return (NULL); + i = 0; + while (i < 4) + dope[i++] = 0; + i = -1; + while (++i < 4 && (j = -1)) + while (av[++j]) + if (comp[i] == av[j]) + dope[i] = 1; + + ft_putendl(av); + i = -1; + while (++i < 4) + ft_putnbr(dope[i]); + ft_putchar('\n'); + return (dope); +} + +/* +** function that check if the password is good to unlock the flags +*/ + +int is_mdp(int ac, char **av) +{ + char *mdp; + int i; + + if (ac != 4) + return (0); + mdp = "trompette"; + i = 0; + while (av[2][i] && mdp[i] && mdp[i] == av[2][i]) + i++; + if (av[2][i] || mdp[i]) + return (0); + return (1); +} + +/* +** main function +*/ + +int main(int ac, char **av) { t_fillist *list; char *input; + int *dope; int size; list = NULL; - if (argc == 2) + if (ac == 2 || is_mdp(ac, av)) { - if (!(input = read_file(argv[1]))) - print_error("error\n"); -// print_error("error: Could not read file.\n"); - if (check_file_errors(input)) - print_error("error\n"); -// print_error("error: Invalid file.\n"); -// print_error_extended(check_file_errors(input)); - size = parse_input(input, &list); - ft_putchar('\n'); - ft_putendl("result for humans :"); + dope = create_dope(av[3]); + if (!(input = read_file(av[1]))) + { + if (dope[3]) + print_error("error: Could not read file.\n"); + else + print_error("error\n"); + } + check_file_errors(input, dope); + size = parse_input(input, &list, dope); + + ft_putchar('\n'); // DEBUG + ft_putendl("result for humans :"); // DEBUG print_final_map(list, size, 1); // DEBUG - ft_putchar('\n'); - ft_putendl("result for moulinette :"); - print_final_map(list, size, 0); // DEBUG + ft_putchar('\n'); // DEBUG + ft_putendl("result for moulinette :"); // DEBUG + + print_final_map(list, size, 0); } else print_error("usage: Please submit a file.\n> ./fillit file.fillit\n"); diff --git a/samples/jdugoudr b/samples/debug/jdugoudr similarity index 100% rename from samples/jdugoudr rename to samples/debug/jdugoudr diff --git a/samples/debug/jdugoudr1 b/samples/debug/jdugoudr1 new file mode 100644 index 0000000..9af3d29 --- /dev/null +++ b/samples/debug/jdugoudr1 @@ -0,0 +1,84 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr10 b/samples/debug/jdugoudr10 new file mode 100644 index 0000000..e063174 --- /dev/null +++ b/samples/debug/jdugoudr10 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr11 b/samples/debug/jdugoudr11 new file mode 100644 index 0000000..42f0f07 --- /dev/null +++ b/samples/debug/jdugoudr11 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr12 b/samples/debug/jdugoudr12 new file mode 100644 index 0000000..ebde261 --- /dev/null +++ b/samples/debug/jdugoudr12 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr13 b/samples/debug/jdugoudr13 new file mode 100644 index 0000000..775d744 --- /dev/null +++ b/samples/debug/jdugoudr13 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr14 b/samples/debug/jdugoudr14 new file mode 100644 index 0000000..86124d0 --- /dev/null +++ b/samples/debug/jdugoudr14 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr15 b/samples/debug/jdugoudr15 new file mode 100644 index 0000000..ed90d73 --- /dev/null +++ b/samples/debug/jdugoudr15 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr16 b/samples/debug/jdugoudr16 new file mode 100644 index 0000000..28a2108 --- /dev/null +++ b/samples/debug/jdugoudr16 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr17 b/samples/debug/jdugoudr17 new file mode 100644 index 0000000..aab8cde --- /dev/null +++ b/samples/debug/jdugoudr17 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr18 b/samples/debug/jdugoudr18 new file mode 100644 index 0000000..36e611d --- /dev/null +++ b/samples/debug/jdugoudr18 @@ -0,0 +1,79 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# diff --git a/samples/debug/jdugoudr18_17 b/samples/debug/jdugoudr18_17 new file mode 100644 index 0000000..36e611d --- /dev/null +++ b/samples/debug/jdugoudr18_17 @@ -0,0 +1,79 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# diff --git a/samples/debug/jdugoudr18_17_16 b/samples/debug/jdugoudr18_17_16 new file mode 100644 index 0000000..8844962 --- /dev/null +++ b/samples/debug/jdugoudr18_17_16 @@ -0,0 +1,74 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... diff --git a/samples/debug/jdugoudr18_17_16_15 b/samples/debug/jdugoudr18_17_16_15 new file mode 100644 index 0000000..0b7ea05 --- /dev/null +++ b/samples/debug/jdugoudr18_17_16_15 @@ -0,0 +1,69 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... diff --git a/samples/debug/jdugoudr18_17_16_15_14 b/samples/debug/jdugoudr18_17_16_15_14 new file mode 100644 index 0000000..05c0611 --- /dev/null +++ b/samples/debug/jdugoudr18_17_16_15_14 @@ -0,0 +1,64 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... diff --git a/samples/debug/jdugoudr18_17_16_15_14_13 b/samples/debug/jdugoudr18_17_16_15_14_13 new file mode 100644 index 0000000..3beb1d4 --- /dev/null +++ b/samples/debug/jdugoudr18_17_16_15_14_13 @@ -0,0 +1,59 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr18_17_16_15_14_13_12 b/samples/debug/jdugoudr18_17_16_15_14_13_12 new file mode 100644 index 0000000..85375db --- /dev/null +++ b/samples/debug/jdugoudr18_17_16_15_14_13_12 @@ -0,0 +1,54 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... diff --git a/samples/debug/jdugoudr18_17_16_15_14_13_12_11 b/samples/debug/jdugoudr18_17_16_15_14_13_12_11 new file mode 100644 index 0000000..c0fe84e --- /dev/null +++ b/samples/debug/jdugoudr18_17_16_15_14_13_12_11 @@ -0,0 +1,49 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# diff --git a/samples/debug/jdugoudr18_17_16_15_14_13_12_11_10 b/samples/debug/jdugoudr18_17_16_15_14_13_12_11_10 new file mode 100644 index 0000000..3b8fdd9 --- /dev/null +++ b/samples/debug/jdugoudr18_17_16_15_14_13_12_11_10 @@ -0,0 +1,44 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_10 b/samples/debug/jdugoudr1_10 new file mode 100644 index 0000000..3eadd0b --- /dev/null +++ b/samples/debug/jdugoudr1_10 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_11 b/samples/debug/jdugoudr1_11 new file mode 100644 index 0000000..685d545 --- /dev/null +++ b/samples/debug/jdugoudr1_11 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_12 b/samples/debug/jdugoudr1_12 new file mode 100644 index 0000000..0cf3681 --- /dev/null +++ b/samples/debug/jdugoudr1_12 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_13 b/samples/debug/jdugoudr1_13 new file mode 100644 index 0000000..4a76ca8 --- /dev/null +++ b/samples/debug/jdugoudr1_13 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_14 b/samples/debug/jdugoudr1_14 new file mode 100644 index 0000000..79ff446 --- /dev/null +++ b/samples/debug/jdugoudr1_14 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_15 b/samples/debug/jdugoudr1_15 new file mode 100644 index 0000000..6427711 --- /dev/null +++ b/samples/debug/jdugoudr1_15 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_16 b/samples/debug/jdugoudr1_16 new file mode 100644 index 0000000..b809cb1 --- /dev/null +++ b/samples/debug/jdugoudr1_16 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_17 b/samples/debug/jdugoudr1_17 new file mode 100644 index 0000000..cb200f9 --- /dev/null +++ b/samples/debug/jdugoudr1_17 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_18 b/samples/debug/jdugoudr1_18 new file mode 100644 index 0000000..22de5f5 --- /dev/null +++ b/samples/debug/jdugoudr1_18 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... diff --git a/samples/debug/jdugoudr1_2 b/samples/debug/jdugoudr1_2 new file mode 100644 index 0000000..b213006 --- /dev/null +++ b/samples/debug/jdugoudr1_2 @@ -0,0 +1,79 @@ +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3 b/samples/debug/jdugoudr1_2_3 new file mode 100644 index 0000000..5680555 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3 @@ -0,0 +1,74 @@ +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4 b/samples/debug/jdugoudr1_2_3_4 new file mode 100644 index 0000000..5780f70 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4 @@ -0,0 +1,69 @@ +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4_5 b/samples/debug/jdugoudr1_2_3_4_5 new file mode 100644 index 0000000..3f51da5 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4_5 @@ -0,0 +1,64 @@ +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4_5_6 b/samples/debug/jdugoudr1_2_3_4_5_6 new file mode 100644 index 0000000..6bff131 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4_5_6 @@ -0,0 +1,59 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4_5_6_7 b/samples/debug/jdugoudr1_2_3_4_5_6_7 new file mode 100644 index 0000000..dda7d14 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4_5_6_7 @@ -0,0 +1,54 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4_5_6_7_8 b/samples/debug/jdugoudr1_2_3_4_5_6_7_8 new file mode 100644 index 0000000..c68ec94 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4_5_6_7_8 @@ -0,0 +1,49 @@ +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4_5_6_7_8_9 b/samples/debug/jdugoudr1_2_3_4_5_6_7_8_9 new file mode 100644 index 0000000..3b8fdd9 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4_5_6_7_8_9 @@ -0,0 +1,44 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_2_3_4_5_6_7_8_9_10 b/samples/debug/jdugoudr1_2_3_4_5_6_7_8_9_10 new file mode 100644 index 0000000..6deecf3 --- /dev/null +++ b/samples/debug/jdugoudr1_2_3_4_5_6_7_8_9_10 @@ -0,0 +1,39 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_3 b/samples/debug/jdugoudr1_3 new file mode 100644 index 0000000..68560bc --- /dev/null +++ b/samples/debug/jdugoudr1_3 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_4 b/samples/debug/jdugoudr1_4 new file mode 100644 index 0000000..3ad9279 --- /dev/null +++ b/samples/debug/jdugoudr1_4 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_5 b/samples/debug/jdugoudr1_5 new file mode 100644 index 0000000..1a5d651 --- /dev/null +++ b/samples/debug/jdugoudr1_5 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_6 b/samples/debug/jdugoudr1_6 new file mode 100644 index 0000000..fdf8daa --- /dev/null +++ b/samples/debug/jdugoudr1_6 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_7 b/samples/debug/jdugoudr1_7 new file mode 100644 index 0000000..9ea86ad --- /dev/null +++ b/samples/debug/jdugoudr1_7 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_8 b/samples/debug/jdugoudr1_8 new file mode 100644 index 0000000..4f5e3d6 --- /dev/null +++ b/samples/debug/jdugoudr1_8 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr1_9 b/samples/debug/jdugoudr1_9 new file mode 100644 index 0000000..94d3cdd --- /dev/null +++ b/samples/debug/jdugoudr1_9 @@ -0,0 +1,79 @@ +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr2 b/samples/debug/jdugoudr2 new file mode 100644 index 0000000..b402092 --- /dev/null +++ b/samples/debug/jdugoudr2 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr3 b/samples/debug/jdugoudr3 new file mode 100644 index 0000000..01c893b --- /dev/null +++ b/samples/debug/jdugoudr3 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr4 b/samples/debug/jdugoudr4 new file mode 100644 index 0000000..2213760 --- /dev/null +++ b/samples/debug/jdugoudr4 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr5 b/samples/debug/jdugoudr5 new file mode 100644 index 0000000..aa32df5 --- /dev/null +++ b/samples/debug/jdugoudr5 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr6 b/samples/debug/jdugoudr6 new file mode 100644 index 0000000..1f8e59d --- /dev/null +++ b/samples/debug/jdugoudr6 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr7 b/samples/debug/jdugoudr7 new file mode 100644 index 0000000..742d649 --- /dev/null +++ b/samples/debug/jdugoudr7 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr8 b/samples/debug/jdugoudr8 new file mode 100644 index 0000000..8345bac --- /dev/null +++ b/samples/debug/jdugoudr8 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +.... +###. +#... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/samples/debug/jdugoudr9 b/samples/debug/jdugoudr9 new file mode 100644 index 0000000..118a6cf --- /dev/null +++ b/samples/debug/jdugoudr9 @@ -0,0 +1,84 @@ +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... + +#### +.... +.... +.... + +.##. +##.. +.... +.... + +##.. +.##. +.... +.... + +...# +...# +...# +...# + +#... +##.. +.#.. +.... + +.... +###. +#... +.... diff --git a/search_map.c b/test_search_map2.c similarity index 88% rename from search_map.c rename to test_search_map2.c index 6acebf1..65f21c8 100644 --- a/search_map.c +++ b/test_search_map2.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */ -/* Updated: 2019/05/21 15:27:37 by hulamy ### ########.fr */ +/* Updated: 2019/05/24 14:41:08 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -215,18 +215,15 @@ int check_tetri_memory(t_fillist *list, int pos) tetri = list; mask = 1 << ((pos % 32) - 1); - if (tetri->same != NULL) + if (tetri->same) { if (!(tetri->same->memory[pos / 32] & mask)) - { - tetri->same->memory[pos / 32] |= mask; - return (1); - } + return (tetri->same->memory[pos / 32] |= mask); } else { - tetri->memory[pos / 32] |= mask; - return (1); +// if (!(tetri->memory[pos / 32] & mask)) + return (tetri->memory[pos / 32] |= mask); } return (0); } @@ -239,16 +236,22 @@ void remove_tetri_memory(t_fillist *list, int pos) tetri = list; mask = 1 << ((pos % 32) - 1); if (tetri->same != NULL) - tetri->same->memory[pos / 32] ^= mask; + { + if ((tetri->same->memory[pos / 32] & mask)) + tetri->same->memory[pos / 32] ^= mask; + } else - tetri->memory[pos / 32] ^= mask; + { + if ((tetri->memory[pos / 32] & mask)) + tetri->memory[pos / 32] ^= mask; + } } /* ** 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) { if (!list) return (1); @@ -256,11 +259,19 @@ int fill_map(unsigned int *map, t_fillist *list, int size) while (find_place(map, list, size)) { add_remove(map, list, size); - if (check_tetri_memory(list, list->position)) - if (fill_map(map, list->next, size)) + + list->test = 1; // DEBUG +// print_final_map(link, size, 1); // DEBUG +// ft_putchar('\n'); // DEBUG + +// if (check_tetri_memory(list, list->position)) + if (fill_map(map, list->next, size, link)) return (1); add_remove(map, list, size); // remove_tetri_memory(list, list->position); + + list->test = 0; // DEBUG + } return (0); } @@ -329,9 +340,18 @@ int search_map(t_fillist *list) while (tmp) { // imression pour tests + check_same_tetri(list, 1); print = tmp->tetribit; print <<= 16; print_map(&print, tmp->width, tmp->height, tmp->letter); + if (tmp->same) + { + print = tmp->same->tetribit; + print <<= 16; + ft_putstr("same --> "); + ft_putchar(tmp->same->letter); + ft_putchar('\n'); + } ft_putchar('\n'); tmp = tmp->next; } @@ -347,15 +367,16 @@ int search_map(t_fillist *list) i = 0; while (!i) { + ft_putnbrendl(size); num = (size * size) / 32 + 1; if (!(map = (unsigned int *)malloc(sizeof(*map) * num))) return (0); check_same_tetri(list, num); while (num) map[num--] = 0; - i = fill_map(map, list, size++); + i = fill_map(map, list, size++, list); } - ft_putendl("result in binary :"); + ft_putendl("result in binary :"); // DEBUG (pas dans le main car besoin de map) print_map(map, size - 1, size - 1, '#'); // DEBUG return (--size); } diff --git a/testmap b/testmap deleted file mode 100755 index 249f914edac0f1be301078e644232c6b5432dba3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13908 zcmeHOVQ?GAbzXpwOv|zliXB%;>>9M9)UGlVE!&A@%L$Mtcia;Q0w%@~ z$%23^PlFk1KqNdJX|v6!Q+eDOPp6r5I`v3xGM1dm5<#m3D|>1xzS{%ezWlSR*D>a5VQk3F7?W`ASixA9 z`A}o*Gq@C7s=6cab@@s8u|FnkeR0);*Mx}AJP1{Fr~JgudJ^8>SC13JGswmu4!?*( zRg;muNvc_;k>9S>m<*cQKV`KO>=Cs5;bB8gP*n$$sqVoVs*&IGzi;vD5EM3ScW4#- zRtkj0PwkDw2O_$a!skHaoHp>Teg)f2$4Psj5%+JIrJmKd;Y{&+bETBfnL3 z{NkbCB;Q)W&oBBA?BqxDy+O3mLsh#6m#mK9`uRTLtCx@ZIQfx{I}5FY<)_=XJ^Br~ zbDQmBFkDV+D-JM~ox)&AE+?-$5eGO4Zls%5JRhJAqWA&tMg1tA#`Jl4Ij=ec+f zU@D)(MRN2$_U@^*o9N)#r20aOgNOgFkk9dvs0?0&^Qm^ zqBfeNd&@frBd(>fG5+Jv4JISI+qbquj#xK{P`-eR##5jV@Md=lnDo;uO${_P(9}Rv z15FM5f6+jfqWx6Kl)V0t$_dH=l(AIxHL7T*M&zn-|EGY`3!;r@$qp%?>kDH zuA-$Yik`xiu4wY2qNNPuS8Ev4(~CeGiZ*F10<;)wa>1Ae6s6KG-7(Bn%=u~Qa$YVG zoR zGwF(3%04c}RP?>A#@FyR08cd((sq`HQN|wrFX+M8cBNXyS{TMSDz&vh>-*HY!EXIA zUSCYn?_FwHgO+Hf1VU9?Rp(+?>i-yow$yYo{`kF0BiG{|P*-BXdbuCb7y)+pNrSsESZz zF`bsZM77EZV5_hBNFq(Xs--F$f|c3xxsSbCdQm!(0;a5|P)lEJbJTO^J#ANYP=0hn zs=P#!JKqX)x{^EZ(k?A)Titf`nP8=5315zCW$DNS3FNo^v4e+3u%ysv~E5qavD-TQ#{k(c%(w5!!S6c=fnYj%1n8um?@|lKd zh>&i+vNR1X&`NBg`WkxZf8mjiTsDsUiq;2M%>{Gsc@bpTFCpj+G(ec_ovchkx={P@>R-;N>#!K@T1ZKnj|@ zUPMd^4;<9}Ug~NVFb&RD56&xEz)JxZW>ql01NkvF?Qqx^tSLC-X{O{?^c6XhmrH>d zlAh1YbD+0I2nXkuw%WWrLk*eq%+1nRyCBhnbHYLA;Gq8fTRQaMjKIt&;hcZuTPq6Y zG)Xv?E=JR?| z>WcnVsJEhQ&P&;q#5{A-|I{1Cb%<8=@sI3*l&z(&Ak-iM%6#O4F&2;mWzvgSI@(*X z66*ld-q!|DWLNjU4Q^KFN#l%&*(PnAHo;*B!K)TQ!EXB-N85{NL!y=Y*o7F!?PCaY zvnl%=lmix*8DZPY^DoQ?7E#esi-^DVnHVCBh(e`@?<}6=y#HZXwWi zI>0kCIwe0riHva@IGcPRvSi~%fG2!ZYe5bCGkK`5WNve)?p~5Dd%L#f5g6w-vNO71)}{s)$W9+XEKq7_Y3o(GV*6)_5;v`C{Y9W9cMgsU4c<>Hj5 zwcR|!waMu@qhOKm1VyAALt7{~VC$n)tEScBHMHtmy@(eDs?T=_nl-Ym>^@ zSQ%*jb!t?!|1{2G%hK}N>+?ih1u+G6C7dN#$rYfnyzwufQMBwdp@^XsB=cDV2v9Tg z`K3Nn!z*Y2me0=NK}F{^@^W5L!qY>?Zsau5uo#R;_mA?9if)Y)K0wHk)n4-$c+{|C zgvCNIYX-(D5=|fDqG@9!kd{4(J30`c=r{Jzvg_CLOlR|HOyel0X|@KZg|AgiQN^!WloppV2ju`VEj7%2a6cb*ziZK zFb=p|kxc1k1SS!|x#cLW8Iw1*1Q)PRV|#f>UXVsdF_<+X{8-=S(Yt15Kh(Nr^sYIK zTE;exs7#(W4bOY4=6Tq8W(#n&=|Eeq^M>F|rxt`fybG}N+hO!_i{jDbla_M|hur{n zmu3w;eX=coLwZI_qf-%M+?~fpWcJeX$ul_vJ6h1d4&OGz*Wb!;7I@^oVg?{FCJj3; z@`4K)NhJn znjaA0SPZBhYI>wKW4Nd$9eM<_URXj(hvZU=Y+&E!DmSFjAJ{5~_|lQC5A@UmB{A4o zKbZwE*Y*xJz|4m(?ey$Nlr{pwYHKqGJE5Gw#me^Z^wxXtdts|~-wV(lvRcHvu7yBm z(%XqH=h~3r@yO##>FZ(ni8EpD7mw4O7zykr4Z8b)54|W|uKMc{U>%YzK^j)#Kem}pD^854rPT!rX z>;D>e##aA`xkm&OjU;9S%jswM+SoKv*w#L~R!N=a+vA%vj7H8Ye*0FZx z!&ft!FlBO7oKISG`p!+K2XwtaCWJzDymaGRmJ8pcs5dXQijBC|a|S$!@F(I~6wi;u zvm%~ucn8s~7SCJ7^IANcxTXf08fa>usez^jni^3<9_;)E&q|c+Ku0h<45g72F^uzagDRY z+J>IdP%O@X_W>V{_YX!0xC=mJZ!Agm4%Byt;_?14K@R}xABgl(-H$pQuTWh<9Y1`J zTP-^PJ)4LniJ2%a6@L@3O5NQH#*uI;8Bu%D72q)WCb@d{i!<|>kGv>&kxak z93QxVibqsVJjj0HO46B+4gNR&5~J`L9NWBnn@b%?^zVI+{S2t`?LZCra2sy}gPv44 zfQRXy`xxwBz7wtSxXNB}<2U{T@lZIz7TrL_29xXxQqVHv`n~W03UW2TxIuA%VGC~YXEd~vUd}{9X{c+&W%XRlFN&`1>eeH#&+TC zkj|AbAGG5~+W1j8!5al!zq!Zm4N9yjoSZCz&mcY;O`5Ve&kK`#Cq&(f z9RgU283MsaqS(mAXPBQO1gMU Date: Mon, 27 May 2019 19:53:27 +0200 Subject: [PATCH 4/5] flags organises --- f_bonus.c => f_bonus_opti.c | 29 ++---- f_bonus_print.c | 77 ++++++++++++++++ f_parse_input.c | 29 +++--- f_print.c | 90 +++++++++++-------- f_read_file.c | 4 +- f_search_map.c | 173 +++++------------------------------- fillit.h | 70 ++++++++++----- main.c | 30 +++---- 8 files changed, 234 insertions(+), 268 deletions(-) rename f_bonus.c => f_bonus_opti.c (79%) create mode 100644 f_bonus_print.c diff --git a/f_bonus.c b/f_bonus_opti.c similarity index 79% rename from f_bonus.c rename to f_bonus_opti.c index 5b4143d..c727dfa 100644 --- a/f_bonus.c +++ b/f_bonus_opti.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/24 14:42:46 by hulamy #+# #+# */ -/* Updated: 2019/05/24 14:46:08 by hulamy ### ########.fr */ +/* Updated: 2019/05/27 19:31:53 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,31 +30,12 @@ int check_tetri_memory(t_fillist *list, int pos) } else { -// if (!(tetri->memory[pos / 32] & mask)) + if (!(tetri->memory[pos / 32] & mask)) return (tetri->memory[pos / 32] |= mask); } return (0); } -void remove_tetri_memory(t_fillist *list, int pos) -{ - t_fillist *tetri; - unsigned int mask; - - tetri = list; - mask = 1 << ((pos % 32) - 1); - if (tetri->same != NULL) - { - if ((tetri->same->memory[pos / 32] & mask)) - tetri->same->memory[pos / 32] ^= mask; - } - else - { - if ((tetri->memory[pos / 32] & mask)) - tetri->memory[pos / 32] ^= mask; - } -} - /* ** Test optimisation for not testing wrong maps when tetri are identical */ @@ -66,7 +47,7 @@ int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b) if (tetri_a->width != tetri_b->width) return (0); if (tetri_a->height != tetri_b->height) - return (0); + return (0); return (1); } @@ -84,7 +65,8 @@ int check_same_tetri(t_fillist *list, int num) while (curr_tetri != NULL) { i = 0; - if (!(curr_tetri->memory = (unsigned int *)malloc(sizeof(*curr_tetri->memory) * num))) + if (!(curr_tetri->memory = + (unsigned int *)malloc(sizeof(*curr_tetri->memory) * num))) return (0); while (i < num) curr_tetri->memory[i++] = 0; @@ -100,4 +82,3 @@ int check_same_tetri(t_fillist *list, int num) } return (0); } - diff --git a/f_bonus_print.c b/f_bonus_print.c new file mode 100644 index 0000000..f7d0a01 --- /dev/null +++ b/f_bonus_print.c @@ -0,0 +1,77 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* f_bonus_print.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: hulamy +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2019/05/27 13:46:29 by hulamy #+# #+# */ +/* Updated: 2019/05/27 19:33:09 by hulamy ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "fillit.h" + +/* +** function that print the given tetris if flag p is present +*/ + +t_fillist *print_tetri(t_fillist *list) +{ + unsigned int print; + t_fillist *tmp; + + tmp = list; + if (list->dope[2]) + { + while (tmp) + { + check_same_tetri(list, 1); + print = tmp->tetribit; + print <<= 16; + print_sized_map(&print, tmp->width, tmp->height, tmp->letter); + if (tmp->same) + { + print = tmp->same->tetribit; + print <<= 16; + ft_putstr("same --> "); + ft_putchar(tmp->same->letter); + ft_putchar('\n'); + } + ft_putchar('\n'); + tmp = tmp->next; + } + } + return (list); +} + +/* +** function that print the map in binary if flag p is present +** it returns anyway the size of the map for main to print it +*/ + +int print_binary_map(unsigned int *map, int size, int *dope) +{ + size--; + if (dope[2]) + { + ft_putendl("result in binary :"); + print_sized_map(map, size, size, '#'); + ft_putchar('\n'); + } + return (size); +} + +/* +** function that print the flags usage +*/ + +int print_flags_usage(void) +{ + ft_putendl("flags usage :"); + ft_putendl("d : debug print (print the map during the backtracking)"); + ft_putendl("o : optimisation ultra fast but with some errors still"); + ft_putendl("p : print the tetri and the map in different formats"); + ft_putendl("e : error msgs more precise AND no error for too much tetri\n"); + return (0); +} diff --git a/f_parse_input.c b/f_parse_input.c index 79c2fc6..3b1ee80 100644 --- a/f_parse_input.c +++ b/f_parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/05/24 18:04:46 by hulamy ### ########.fr */ +/* Updated: 2019/05/27 19:43:06 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,10 +44,7 @@ unsigned short reduce_tetri(unsigned short tetri, int width) unsigned int mask; unsigned int tmp; - // cree un mask avec des 1 a gauche sur la largeur du tetriminos mask = ~0u << (32 - width) >> 16; - // fabrique la ligne pour le tetriminos de la bonne largeur - tmp = tetri; tmp = (mask & tetri); tmp |= ((mask & tetri << 4) >> width); tmp |= ((mask & tetri << 8) >> (2 * width)); @@ -66,9 +63,12 @@ unsigned short reduce_tetri(unsigned short tetri, int width) ** (i - list->width = le nombre de colonne vide a gauche) ** 5) trouve la hauteur du tetri ** 6) fabrique la ligne pour le tetriminos de la bonne largeur +** +** list->test is used to debug the backtracking, allowing to print the +** map each time without the previous tries */ -void fill_list(char line[], t_fillist *list) +void fill_list(char line[], t_fillist *list) { unsigned int mask; int i; @@ -92,7 +92,7 @@ void fill_list(char line[], t_fillist *list) list->height = i; list->tetribit = reduce_tetri(list->tetribit, list->width); list->same = NULL; - list->test = 0; // DEBUG pour que print_final_map puisse imprimer correctement au fur et a mesure + list->test = 0; } /* @@ -100,7 +100,7 @@ void fill_list(char line[], t_fillist *list) ** linked each time needed */ -int add_to_list(char *line, t_fillist **list, char letter) +int add_to_list(char *line, t_fillist **lst, char letter, int *dope) { t_fillist *tmp; t_fillist *test; @@ -108,17 +108,19 @@ int add_to_list(char *line, t_fillist **list, char letter) if (!(tmp = (t_fillist*)malloc(sizeof(*tmp)))) return (0); tmp->next = NULL; - test = *list; + test = *lst; if (!test) - *list = tmp; + *lst = tmp; else { - while(test->next) + while (test->next) test = test->next; test->next = tmp; } fill_list(line, tmp); tmp->letter = letter; + tmp->dope = dope; + tmp->start = *lst; return (1); } @@ -126,12 +128,13 @@ int add_to_list(char *line, t_fillist **list, char letter) ** Function that parse a file and put each tetrimino in a linked list */ -int parse_input(char *input, t_fillist **list, int *dope) +int parse_input(char *input, t_fillist **list, int *dope) { char tetri[20]; int i; int j; int letter; + int size; i = 0; letter = 'A'; @@ -145,10 +148,10 @@ int parse_input(char *input, t_fillist **list, int *dope) print_error("error\n"); // print_error("error: Wrong tetrimino.\n"); // print_error_extended(check_tetri_errors(tetri)); - add_to_list(tetri, list, letter++); + add_to_list(tetri, list, letter++, dope); while (input[i] && input[i] != '.' && input[i] != '#') i++; } - int size = search_map(*list); + size = search_map(*list); return (size); } diff --git a/f_print.c b/f_print.c index bfc4f54..219514f 100644 --- a/f_print.c +++ b/f_print.c @@ -6,37 +6,18 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/30 13:24:28 by hulamy #+# #+# */ -/* Updated: 2019/05/22 14:34:45 by hulamy ### ########.fr */ +/* Updated: 2019/05/27 19:47:11 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" /* -** DELETE BEFORE EVAL - TEST FUNCTION -** Prints a ligne of size bits +** function that print a map of height and width +** usefull to print tetris */ -void print_bits(unsigned int bits, int size) -{ - unsigned int mask; - - mask = 1 << (size - 1); - while (mask) - { - (bits & mask) ? write(1, "#", 1) : write(1, ".", 1); - write(1, " ", 1); - mask >>= 1; - } - write(1, "\n", 1); -} - -/* -** DELETE BEFORE EVAL - TEST FUNCTION -** Print a map of height and width -*/ - -void print_map(unsigned int *tab, int width, int height, char letter) +void print_sized_map(unsigned int *tab, int width, int height, char letter) { int i; unsigned int mask; @@ -50,7 +31,10 @@ void print_map(unsigned int *tab, int width, int height, char letter) { if (i && !(i % width)) ft_putchar('\n'); - tab[i / 32] & (1 << (31 - i % 32)) ? ft_put_tetri_color(letter) : ft_putchar('.'); + if (tab[i / 32] & (1 << (31 - i % 32))) + ft_put_tetri_color(letter); + else + ft_putchar('.'); ft_putchar(' '); i++; } @@ -59,42 +43,56 @@ void print_map(unsigned int *tab, int width, int height, char letter) /* ** Print the final map with the letters +** if flag value is 0 -> print moulinette version +** if flag value is 0 -> print in color */ -void print_final_map(t_fillist *list, int size, int flag) // DEBUG flag vaut 0 pour imprimer comme rendu et 1 pour imprimer en couleur +char *init_print_map(t_fillist *list, int size) { - t_fillist *tmp; char *map; int i; int j; map = (char *)malloc(sizeof(*map) * (size * size + 1)); - map[size*size] = '\0'; + map[size * size] = '\0'; i = -1; while (++i < size * size) map[i] = '.'; - tmp = list; - while (tmp) + while (list) { j = 0; i = -1; - while (++i < tmp->width * tmp->height) + while (++i < list->width * list->height) { - if (i && i % tmp->width == 0) - j += size - tmp->width; - if (1 << (15 - i) & tmp->tetribit && tmp->test == 1) // DEBUG "&& tmp->test == 1" pour imprimer les bonnes lettres au coours du debug - map[tmp->position + i + j - 1] = tmp->letter; + if (i && i % list->width == 0) + j += size - list->width; + if (1 << (15 - i) & list->tetribit && list->test == 1) + map[list->position + i + j - 1] = list->letter; } - tmp = tmp->next; + list = list->next; } + return (map); +} + +/* +** Function that print the map with color if flag = 1 +** or for moulinette if flag = 0; +*/ + +void print_letter_map(t_fillist *list, int size, int flag) +{ + int i; + char *map; + + map = init_print_map(list, size); i = -1; while (++i < size * size) { if (i && i % size == 0) ft_putchar('\n'); - if (flag == 0) // DEBUG imprim comme rendu + if (flag == 0) ft_putchar(map[i]); - else // DEBUG imprim avec couleurs + else { ft_put_tetri_color(map[i]); ft_putchar(' '); @@ -102,3 +100,21 @@ void print_final_map(t_fillist *list, int size, int flag) // DEBUG flag vaut 0 p } ft_putchar('\n'); } + +/* +** Function that print the map +*/ + +void print_final_map(t_fillist *list, int size) +{ + if (list->dope[2]) + { + ft_putendl("result for humans :"); + print_letter_map(list, size, 1); + ft_putchar('\n'); + ft_putendl("result for moulinette :"); + } + print_letter_map(list, size, 0); + if (list->dope[2]) + ft_putchar('\n'); +} diff --git a/f_read_file.c b/f_read_file.c index 72f1e58..edacbfd 100644 --- a/f_read_file.c +++ b/f_read_file.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/13 12:09:46 by vmanzoni #+# #+# */ -/* Updated: 2019/04/22 15:16:18 by vmanzoni ### ########.fr */ +/* Updated: 2019/05/27 19:46:54 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,7 +26,7 @@ char *read_file(char *file) if (((fd = open(file, O_RDONLY)) < 0) \ || ((rv = read(fd, &buf, BUFF_SIZE)) < 0) \ - || !(result = malloc(sizeof(char) * rv))) + || !(result = malloc(sizeof(char) * rv))) return (NULL); buf[rv] = '\0'; i = -1; diff --git a/f_search_map.c b/f_search_map.c index 03d6628..ef8b97e 100644 --- a/f_search_map.c +++ b/f_search_map.c @@ -6,116 +6,12 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */ -/* Updated: 2019/05/24 14:48:33 by hulamy ### ########.fr */ +/* Updated: 2019/05/27 19:30:37 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "fillit.h" -/* -** OLD VERSION of find_place and fit_in_place all in one but with a lot of divisions and modulo -** -** int find_place(unsigned int *tab, t_fillist *list, int size, int pos) -** { -** int i; -** int j; -** unsigned int mask; -** unsigned int tmp; -** -** mask = ~0u << (32 - list->width); -** tmp = mask; -** i = pos; -** while (i < (size - list->height + 1) * size) -** { -** if (i % size == size - list->width + 1) -** i += list->width - 1; -** else -** { -** tmp = 0; -** j = (list->height - 1) * size + i; -** while (j >= i) -** { -** tmp >>= list->width; -** tmp |= (mask & (tab[j / 32] << j)); -** tmp |= (mask & (tab[(j + list->width) / 32] >> (32 - j))); -** j -= size; -** } -** if (!((tmp >> 16) & list->tetribit)) -** return (i + 1); -** i++; -** } -** } -** return (0); -** } -*/ - -/* -** function that try to optimize the speed -** SECOND ATTEMPT -** by finding the isolated dots whille fillling the map -** untill they get more numerous than the max amount available -** TOTAL FAILURE :p -** -** int check_others(unsigned int *map, t_fillist *list, int size, int num) -** { -** t_fillist *tmp; -** int dots; -** int total; -** int i; -** int j; -** -** dots = 0; -** i = -1; -** num *= 4; -** total = size * size; -** while (++i < total && dots <= total - num) -** { -** tmp = list->next; -** j = 1; -** // saute les position pas vides -** while (1 << (i % 32) & map[i % 32]) -** i++; -** // pour chaque position vide regarde si chaque tetri non encode places peuvent y rentrer -** while (j && tmp) -** { -** // si le tetri est trop a droite ou trop en bas il ne rentre pas ce n'est pas la peine de chercher donc on passe au tetri suivant -** if (tmp->width > (size - i % size) || (total - i) <= (tmp->height * size)) -** tmp = tmp->next; -** // sinon verifier si on peut le mettre a cette position et si on ne peut pas passer au tetri suivant -** else if (!fit_in_place(map, list, size, i)) -** tmp = tmp->next; -** // si le tetri peut rentrer on arrete la boucle en mettant j = 0 -** else -** j = 0; -** } -** // si j existe c que le tetri ne pouvait pas etre place donc on rajoute 1 au compteur de point isoles -** if (j) -** dots++; -** } -** return (dots > total - num); -** } -*/ - -/* -** function that try to optimize the speed -** FIRST ATTEMPT -** by verifying if the place left is enough to place at least -** one of each tetri left -** TOTAL FAILURE :p -** -** int check_others(unsigned int *map, t_fillist *list, int size, int num) -** { -** t_fillist *tmp; -** -** // verifie que les tetri restant puissent un par un se placer sur la map -** // ca n'optimise qu'en fin de map donc ca ralentit les grosses map en fait -** while ((tmp = tmp->next)) -** if (!find_place(map, tmp, size, 0)) -** return (0); -** return (1); -** } -*/ - /* ** function that look if a tretri fit in a place */ @@ -151,7 +47,7 @@ unsigned int fit_in_place(unsigned int *map, t_fillist *lst, int size, int i) ** function that look for the first place in the map for a tetri */ -int find_place(unsigned int *map, t_fillist *list, int size) +int find_place(unsigned int *map, t_fillist *list, int size) { int limit; int pos; @@ -184,7 +80,7 @@ int find_place(unsigned int *map, t_fillist *list, int size) ** function that add or remove a tetri on the map */ -void add_remove(unsigned int *map, t_fillist *list, int size) +void add_remove(unsigned int *map, t_fillist *list, int size) { unsigned int mask; unsigned short tetri; @@ -208,7 +104,7 @@ void add_remove(unsigned int *map, t_fillist *list, int size) ** Function that recursively try to fill the map with the tetris */ -int fill_map(unsigned int *map, t_fillist *list, int size, t_fillist *link) +int fill_map(unsigned int *map, t_fillist *list, int size) { if (!list) return (1); @@ -216,28 +112,31 @@ int fill_map(unsigned int *map, t_fillist *list, int size, t_fillist *link) while (find_place(map, list, size)) { add_remove(map, list, size); - - list->test = 1; // DEBUG -// print_final_map(link, size, 1); // DEBUG -// ft_putchar('\n'); // DEBUG - - if (check_tetri_memory(list, list->position)) - if (fill_map(map, list->next, size, link)) + list->test = 1; + if (list->dope[0]) + { + print_letter_map(list->start, size, 1); + ft_putchar('\n'); + } + if (list->dope[1]) + if (check_tetri_memory(list, list->position)) + if (fill_map(map, list->next, size)) + return (1); + if (!list->dope[1]) + if (fill_map(map, list->next, size)) return (1); add_remove(map, list, size); -// remove_tetri_memory(list, list->position); - - list->test = 0; // DEBUG - + list->test = 0; } return (0); } /* -** function that send to "fill_map" a map of a certain size and increment its size untill it's solved +** function that send to "fill_map" a map of a certain size +** and increment its size untill it's solved */ -int search_map(t_fillist *list) +int search_map(t_fillist *list) { t_fillist *tmp; unsigned int *map; @@ -245,32 +144,9 @@ int search_map(t_fillist *list) int num; int i; - /////////////////////////////////////////////////// TEST - unsigned int print; - tmp = list; - while (tmp) - { - // imression pour tests - check_same_tetri(list, 1); - print = tmp->tetribit; - print <<= 16; - print_map(&print, tmp->width, tmp->height, tmp->letter); - if (tmp->same) - { - print = tmp->same->tetribit; - print <<= 16; - ft_putstr("same --> "); - ft_putchar(tmp->same->letter); - ft_putchar('\n'); - } - ft_putchar('\n'); - tmp = tmp->next; - } - /////////////////////////////////////////////////// TEST - size = 2; num = 1; - tmp = list; + tmp = print_tetri(list); while ((tmp = tmp->next)) num++; while (size * size < num * 4) @@ -278,16 +154,13 @@ int search_map(t_fillist *list) i = 0; while (!i) { - ft_putnbrendl(size); num = (size * size) / 32 + 1; if (!(map = (unsigned int *)malloc(sizeof(*map) * num))) return (0); check_same_tetri(list, num); while (num) map[num--] = 0; - i = fill_map(map, list, size++, list); + i = fill_map(map, list, size++); } - ft_putendl("result in binary :"); // DEBUG (pas dans le main car besoin de map) - print_map(map, size - 1, size - 1, '#'); // DEBUG - return (--size); + return (print_binary_map(map, size, list->dope)); } diff --git a/fillit.h b/fillit.h index 05b191d..c919198 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/24 18:04:17 by hulamy ### ########.fr */ +/* Updated: 2019/05/27 19:26:04 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,50 +57,74 @@ typedef struct s_fillist int num; int test; char letter; + int *dope; unsigned int *memory; struct s_fillist *same; struct s_fillist *next; + struct s_fillist *start; } t_fillist; +/* +** bonus_print.c +*/ +t_fillist *print_tetri(t_fillist *list); +int print_binary_map(unsigned int *map, int size, int *dope); +int print_flags_usage(void); + +/* +** bonus_opti.c +*/ +int check_same_tetri(t_fillist *list, int num); +int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b); +int check_tetri_memory(t_fillist *list, int pos); + /* ** main.c */ -int main(int argc, char **argv); -int *create_dope(char *av); -int is_mdp(int ac, char **av); +int main(int argc, char **argv); +int *create_dope(char *av, int mdp); +int is_mdp(int ac, char **av); /* ** read_file.c */ -char *read_file(char *file); +char *read_file(char *file); /* ** handle_errors.c */ -void print_error(char *s); -void print_error_extended(int error, int *dope); -int check_file_errors(char *file, int *dope); -int check_tetri_errors(char *tetri); -int check_tetri_errors_proxy(char *tetri); +void print_error(char *s); +void print_error_extended(int error, int *dope); +void check_file_errors(char *file, int *dope); +int check_tetri_errors(char *tetri); +int check_tetri_errors_proxy(char *tetri); /* -** handle_errors.c +** parse_input.c */ -int parse_input(char *input, t_fillist **list, int *dope); -int add_to_list(char *square, t_fillist **list, char letter); -void fill_list(char line[], t_fillist *list); +int parse_input(char *input, t_fillist **list, int *dope); +int add_to_list(char *sqr, t_fillist **lst, char lett, int *dope); +void fill_list(char line[], t_fillist *list); unsigned short reduce_tetri(unsigned short tetri, int width); unsigned short tab_to_bin(char line[]); -void print_bits(unsigned int bits, int size); //TO DELETE BEFORE EVAL -void print_tetri(unsigned int bits, int size); //TO DELETE BEFORE EVAL -int 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, int flag); +/* +** search_map.c +*/ +unsigned int fit_in_place(unsigned int *map, t_fillist *lst, int siz, int i); +int find_place(unsigned int *map, t_fillist *list, int size); +void add_remove(unsigned int *map, t_fillist *list, int size); +int fill_map(unsigned int *map, t_fillist *list, int size); +int search_map(t_fillist *list); + +/* +** print.c +*/ +void print_sized_map(unsigned int *tab, int width, int height, char letter); +char *init_print_map(t_fillist *list, int size); +void print_letter_map(t_fillist *list, int size, int flag); +void print_final_map(t_fillist *list, int size); + void ft_put_tetri_color(char c); -int check_tetri_memory(t_fillist *list, int pos); -void remove_tetri_memory(t_fillist *list, int pos); -int check_same_tetri(t_fillist *list, int num); -int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b); #endif diff --git a/main.c b/main.c index 39d35f9..f349f08 100644 --- a/main.c +++ b/main.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */ -/* Updated: 2019/05/24 18:02:29 by hulamy ### ########.fr */ +/* Updated: 2019/05/27 18:21:58 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ ** e : error extended (error message more precise AND no error for too much tetri) */ -int *create_dope(char *av) +int *create_dope(char *av, int mdp) { char *comp; int *dope; @@ -34,17 +34,13 @@ int *create_dope(char *av) i = 0; while (i < 4) dope[i++] = 0; + if (!mdp) + return (dope); i = -1; while (++i < 4 && (j = -1)) while (av[++j]) if (comp[i] == av[j]) dope[i] = 1; - - ft_putendl(av); - i = -1; - while (++i < 4) - ft_putnbr(dope[i]); - ft_putchar('\n'); return (dope); } @@ -57,7 +53,7 @@ int is_mdp(int ac, char **av) char *mdp; int i; - if (ac != 4) + if (ac < 3 || ac > 4) return (0); mdp = "trompette"; i = 0; @@ -65,6 +61,8 @@ int is_mdp(int ac, char **av) i++; if (av[2][i] || mdp[i]) return (0); + if (ac == 3) + return (print_flags_usage()); return (1); } @@ -78,11 +76,12 @@ int main(int ac, char **av) char *input; int *dope; int size; + int mdp; list = NULL; - if (ac == 2 || is_mdp(ac, av)) + dope = create_dope(av[3], (mdp = is_mdp(ac, av))); + if (ac == 2 || mdp) { - dope = create_dope(av[3]); if (!(input = read_file(av[1]))) { if (dope[3]) @@ -92,14 +91,7 @@ int main(int ac, char **av) } check_file_errors(input, dope); size = parse_input(input, &list, dope); - - ft_putchar('\n'); // DEBUG - ft_putendl("result for humans :"); // DEBUG - print_final_map(list, size, 1); // DEBUG - ft_putchar('\n'); // DEBUG - ft_putendl("result for moulinette :"); // DEBUG - - print_final_map(list, size, 0); + print_final_map(list, size); } else print_error("usage: Please submit a file.\n> ./fillit file.fillit\n"); From 77656ba113dd8e6124fa1c6dba0fed70517092e4 Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Tue, 28 May 2019 13:05:14 +0200 Subject: [PATCH 5/5] sans l'opion o opti les sames ne s'affichent pas --- f_bonus_opti.c | 4 ++-- f_bonus_print.c | 4 ++-- f_handle_errors.c | 5 +++-- f_parse_input.c | 7 ++++--- f_search_map.c | 5 +++-- fillit.dSYM/Contents/Info.plist | 20 ++++++++++++++++++++ fillit.h | 17 ++++++++++++++++- 7 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 fillit.dSYM/Contents/Info.plist diff --git a/f_bonus_opti.c b/f_bonus_opti.c index c727dfa..463730d 100644 --- a/f_bonus_opti.c +++ b/f_bonus_opti.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/24 14:42:46 by hulamy #+# #+# */ -/* Updated: 2019/05/27 19:31:53 by hulamy ### ########.fr */ +/* Updated: 2019/05/28 13:03:46 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -62,7 +62,7 @@ int check_same_tetri(t_fillist *list, int num) int i; curr_tetri = list; - while (curr_tetri != NULL) + while (curr_tetri != NULL/* && list->dope[1]*/) { i = 0; if (!(curr_tetri->memory = diff --git a/f_bonus_print.c b/f_bonus_print.c index f7d0a01..5076c6b 100644 --- a/f_bonus_print.c +++ b/f_bonus_print.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/05/27 13:46:29 by hulamy #+# #+# */ -/* Updated: 2019/05/27 19:33:09 by hulamy ### ########.fr */ +/* Updated: 2019/05/28 09:57:40 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,7 +35,7 @@ t_fillist *print_tetri(t_fillist *list) print = tmp->same->tetribit; print <<= 16; ft_putstr("same --> "); - ft_putchar(tmp->same->letter); + ft_put_tetri_color(tmp->same->letter); ft_putchar('\n'); } ft_putchar('\n'); diff --git a/f_handle_errors.c b/f_handle_errors.c index 230cc2a..5377be0 100644 --- a/f_handle_errors.c +++ b/f_handle_errors.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */ -/* Updated: 2019/05/24 18:02:08 by hulamy ### ########.fr */ +/* Updated: 2019/05/28 11:26:25 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,8 +69,9 @@ void check_file_errors(char *file, int *dope) print_error_extended(1, dope); else if (file[i] == '\n') line_nbr++; + // le if suivant verifie quoi if (file[i] == '\n' && line_nbr % 5 == 0 && file[i-1] != '\n') - print_error("error\n"); // est-ce que ca n'imprime pas error deux fois ?? + print_error("error\n"); if (file[i] == '\n' && file[i+1] != '\0' && \ file[i+2] != '.' && file[i+2] != '#') print_error_extended(2, dope); diff --git a/f_parse_input.c b/f_parse_input.c index 3b1ee80..1594cc1 100644 --- a/f_parse_input.c +++ b/f_parse_input.c @@ -6,7 +6,7 @@ /* By: vmanzoni +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */ -/* Updated: 2019/05/27 19:43:06 by hulamy ### ########.fr */ +/* Updated: 2019/05/28 10:44:43 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -144,10 +144,11 @@ int parse_input(char *input, t_fillist **list, int *dope) while (j < 19) tetri[j++] = input[i++]; tetri[19] = '\0'; + // "wrong tetrimino" utile ? if (check_tetri_errors(tetri)) - print_error("error\n"); +// print_error("error\n"); // print_error("error: Wrong tetrimino.\n"); -// print_error_extended(check_tetri_errors(tetri)); + print_error_extended(check_tetri_errors(tetri), dope); add_to_list(tetri, list, letter++, dope); while (input[i] && input[i] != '.' && input[i] != '#') i++; diff --git a/f_search_map.c b/f_search_map.c index ef8b97e..0eb4b7e 100644 --- a/f_search_map.c +++ b/f_search_map.c @@ -6,7 +6,7 @@ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */ -/* Updated: 2019/05/27 19:30:37 by hulamy ### ########.fr */ +/* Updated: 2019/05/28 11:56:18 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -94,7 +94,8 @@ void add_remove(unsigned int *map, t_fillist *list, int size) while (j >= list->position) { map[(j - 1) / 32] ^= (mask & tetri << (16 + i)) >> (j - 1); - map[(j - 1) / 32 + 1] ^= (mask & tetri << (16 + i)) << (32 - j) << 1; + if (map[(j - 1) / 32 + 1]) + map[(j - 1) / 32 + 1] ^= (mask & tetri << (16 + i)) << (32 - j) << 1; j -= size; i -= list->width; } diff --git a/fillit.dSYM/Contents/Info.plist b/fillit.dSYM/Contents/Info.plist new file mode 100644 index 0000000..96bfe2d --- /dev/null +++ b/fillit.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.fillit + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/fillit.h b/fillit.h index c919198..067ab24 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/27 19:26:04 by hulamy ### ########.fr */ +/* Updated: 2019/05/28 12:15:39 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ @@ -45,6 +45,21 @@ /* ** STRUCTURE +** tetribit : tetri ecrit en binaire dans un short de 16 bits +** width : largeur du tetri +** height : hauteur du tetri +** position : memorise la position d tetri bit a bit +** place : position sur l'axe des abscisses de la map (position % size) +** rank : position de 1 a 32 dans l'int du tableau d'int (position % 32) +** num : memorise dans quel int du tableau on se trouve (position / 32) +** total_num : le nombre d'int dans le tableau d'int +** test : +** letter : +** dope : +** memory : +** same : +** next : +** start : */ typedef struct s_fillist {