diff --git a/.cache/clangd/index/ai.c.A50E4BCF59F9D441.idx b/.cache/clangd/index/ai.c.A50E4BCF59F9D441.idx new file mode 100644 index 0000000..f2761ff Binary files /dev/null and b/.cache/clangd/index/ai.c.A50E4BCF59F9D441.idx differ diff --git a/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx b/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx index f020cd5..2757068 100644 Binary files a/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx and b/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx differ diff --git a/.cache/clangd/index/check_input.c.D27AA41095D26EB5.idx b/.cache/clangd/index/check_input.c.D27AA41095D26EB5.idx index 47f685c..1710bd2 100644 Binary files a/.cache/clangd/index/check_input.c.D27AA41095D26EB5.idx and b/.cache/clangd/index/check_input.c.D27AA41095D26EB5.idx differ diff --git a/.cache/clangd/index/fill_array.c.990BCC54FAB801D3.idx b/.cache/clangd/index/fill_array.c.990BCC54FAB801D3.idx index 4c5f3d8..2f4627e 100644 Binary files a/.cache/clangd/index/fill_array.c.990BCC54FAB801D3.idx and b/.cache/clangd/index/fill_array.c.990BCC54FAB801D3.idx differ diff --git a/.cache/clangd/index/ft_atoi.c.AAC0C85CD5A3334A.idx b/.cache/clangd/index/ft_atoi.c.AAC0C85CD5A3334A.idx new file mode 100644 index 0000000..66378d7 Binary files /dev/null and b/.cache/clangd/index/ft_atoi.c.AAC0C85CD5A3334A.idx differ diff --git a/.cache/clangd/index/ft_bzero.c.DAC107111976FAAB.idx b/.cache/clangd/index/ft_bzero.c.DAC107111976FAAB.idx new file mode 100644 index 0000000..09676ac Binary files /dev/null and b/.cache/clangd/index/ft_bzero.c.DAC107111976FAAB.idx differ diff --git a/.cache/clangd/index/ft_calloc.c.10157C071BB8E972.idx b/.cache/clangd/index/ft_calloc.c.10157C071BB8E972.idx new file mode 100644 index 0000000..0c6e35d Binary files /dev/null and b/.cache/clangd/index/ft_calloc.c.10157C071BB8E972.idx differ diff --git a/.cache/clangd/index/ft_isalnum.c.9726620C3AA51CF7.idx b/.cache/clangd/index/ft_isalnum.c.9726620C3AA51CF7.idx new file mode 100644 index 0000000..88b194f Binary files /dev/null and b/.cache/clangd/index/ft_isalnum.c.9726620C3AA51CF7.idx differ diff --git a/.cache/clangd/index/ft_isalpha.c.28007DD25B0D54C8.idx b/.cache/clangd/index/ft_isalpha.c.28007DD25B0D54C8.idx new file mode 100644 index 0000000..2960b93 Binary files /dev/null and b/.cache/clangd/index/ft_isalpha.c.28007DD25B0D54C8.idx differ diff --git a/.cache/clangd/index/ft_isascii.c.691DFC1D9219DD8D.idx b/.cache/clangd/index/ft_isascii.c.691DFC1D9219DD8D.idx new file mode 100644 index 0000000..513f61f Binary files /dev/null and b/.cache/clangd/index/ft_isascii.c.691DFC1D9219DD8D.idx differ diff --git a/.cache/clangd/index/ft_isdigit.c.FDF926DEC463B471.idx b/.cache/clangd/index/ft_isdigit.c.FDF926DEC463B471.idx new file mode 100644 index 0000000..40941b7 Binary files /dev/null and b/.cache/clangd/index/ft_isdigit.c.FDF926DEC463B471.idx differ diff --git a/.cache/clangd/index/ft_isprint.c.A68CFCA5D89065F6.idx b/.cache/clangd/index/ft_isprint.c.A68CFCA5D89065F6.idx new file mode 100644 index 0000000..39ac0f2 Binary files /dev/null and b/.cache/clangd/index/ft_isprint.c.A68CFCA5D89065F6.idx differ diff --git a/.cache/clangd/index/ft_itoa.c.AD9367D7015DA61A.idx b/.cache/clangd/index/ft_itoa.c.AD9367D7015DA61A.idx new file mode 100644 index 0000000..320531a Binary files /dev/null and b/.cache/clangd/index/ft_itoa.c.AD9367D7015DA61A.idx differ diff --git a/.cache/clangd/index/ft_memchr.c.047CCF6FB621D6AD.idx b/.cache/clangd/index/ft_memchr.c.047CCF6FB621D6AD.idx new file mode 100644 index 0000000..6ca34f9 Binary files /dev/null and b/.cache/clangd/index/ft_memchr.c.047CCF6FB621D6AD.idx differ diff --git a/.cache/clangd/index/ft_memcmp.c.E6FD67EFD6E31D86.idx b/.cache/clangd/index/ft_memcmp.c.E6FD67EFD6E31D86.idx new file mode 100644 index 0000000..bf0323c Binary files /dev/null and b/.cache/clangd/index/ft_memcmp.c.E6FD67EFD6E31D86.idx differ diff --git a/.cache/clangd/index/ft_memcpy.c.E00A74572EBFD6A6.idx b/.cache/clangd/index/ft_memcpy.c.E00A74572EBFD6A6.idx new file mode 100644 index 0000000..44e38fb Binary files /dev/null and b/.cache/clangd/index/ft_memcpy.c.E00A74572EBFD6A6.idx differ diff --git a/.cache/clangd/index/ft_memmove.c.A35DCCA87F6B72AB.idx b/.cache/clangd/index/ft_memmove.c.A35DCCA87F6B72AB.idx new file mode 100644 index 0000000..fe902cd Binary files /dev/null and b/.cache/clangd/index/ft_memmove.c.A35DCCA87F6B72AB.idx differ diff --git a/.cache/clangd/index/ft_memset.c.C2402FA78CA3CDA0.idx b/.cache/clangd/index/ft_memset.c.C2402FA78CA3CDA0.idx new file mode 100644 index 0000000..a9367ad Binary files /dev/null and b/.cache/clangd/index/ft_memset.c.C2402FA78CA3CDA0.idx differ diff --git a/.cache/clangd/index/ft_putchar_fd.c.DCAE755DD8CFF5C2.idx b/.cache/clangd/index/ft_putchar_fd.c.DCAE755DD8CFF5C2.idx new file mode 100644 index 0000000..09b5458 Binary files /dev/null and b/.cache/clangd/index/ft_putchar_fd.c.DCAE755DD8CFF5C2.idx differ diff --git a/.cache/clangd/index/ft_putendl_fd.c.EA696FEC111A6733.idx b/.cache/clangd/index/ft_putendl_fd.c.EA696FEC111A6733.idx new file mode 100644 index 0000000..e18d38f Binary files /dev/null and b/.cache/clangd/index/ft_putendl_fd.c.EA696FEC111A6733.idx differ diff --git a/.cache/clangd/index/ft_putnbr_fd.c.0577D1D6EEFA2E6C.idx b/.cache/clangd/index/ft_putnbr_fd.c.0577D1D6EEFA2E6C.idx new file mode 100644 index 0000000..6bf6551 Binary files /dev/null and b/.cache/clangd/index/ft_putnbr_fd.c.0577D1D6EEFA2E6C.idx differ diff --git a/.cache/clangd/index/ft_putstr_fd.c.452F9FEE2DC8D0E4.idx b/.cache/clangd/index/ft_putstr_fd.c.452F9FEE2DC8D0E4.idx new file mode 100644 index 0000000..c41961e Binary files /dev/null and b/.cache/clangd/index/ft_putstr_fd.c.452F9FEE2DC8D0E4.idx differ diff --git a/.cache/clangd/index/ft_split.c.0A611BF6D5EE9DD3.idx b/.cache/clangd/index/ft_split.c.0A611BF6D5EE9DD3.idx new file mode 100644 index 0000000..363f829 Binary files /dev/null and b/.cache/clangd/index/ft_split.c.0A611BF6D5EE9DD3.idx differ diff --git a/.cache/clangd/index/ft_strchr.c.0AEC7670B61A66CC.idx b/.cache/clangd/index/ft_strchr.c.0AEC7670B61A66CC.idx new file mode 100644 index 0000000..ad84d12 Binary files /dev/null and b/.cache/clangd/index/ft_strchr.c.0AEC7670B61A66CC.idx differ diff --git a/.cache/clangd/index/ft_strdup.c.6EC5C92AC323DA06.idx b/.cache/clangd/index/ft_strdup.c.6EC5C92AC323DA06.idx new file mode 100644 index 0000000..b63e574 Binary files /dev/null and b/.cache/clangd/index/ft_strdup.c.6EC5C92AC323DA06.idx differ diff --git a/.cache/clangd/index/ft_striteri.c.28BBB5646AC16566.idx b/.cache/clangd/index/ft_striteri.c.28BBB5646AC16566.idx new file mode 100644 index 0000000..0101813 Binary files /dev/null and b/.cache/clangd/index/ft_striteri.c.28BBB5646AC16566.idx differ diff --git a/.cache/clangd/index/ft_strjoin.c.81CF224EB2B0C0DE.idx b/.cache/clangd/index/ft_strjoin.c.81CF224EB2B0C0DE.idx new file mode 100644 index 0000000..b135197 Binary files /dev/null and b/.cache/clangd/index/ft_strjoin.c.81CF224EB2B0C0DE.idx differ diff --git a/.cache/clangd/index/ft_strlcat.c.8FB584B2E6F00754.idx b/.cache/clangd/index/ft_strlcat.c.8FB584B2E6F00754.idx new file mode 100644 index 0000000..236e5ac Binary files /dev/null and b/.cache/clangd/index/ft_strlcat.c.8FB584B2E6F00754.idx differ diff --git a/.cache/clangd/index/ft_strlcpy.c.D41441F6B29B55DE.idx b/.cache/clangd/index/ft_strlcpy.c.D41441F6B29B55DE.idx new file mode 100644 index 0000000..b687865 Binary files /dev/null and b/.cache/clangd/index/ft_strlcpy.c.D41441F6B29B55DE.idx differ diff --git a/.cache/clangd/index/ft_strlen.c.A0CCD4D07FD631AB.idx b/.cache/clangd/index/ft_strlen.c.A0CCD4D07FD631AB.idx new file mode 100644 index 0000000..b5c9045 Binary files /dev/null and b/.cache/clangd/index/ft_strlen.c.A0CCD4D07FD631AB.idx differ diff --git a/.cache/clangd/index/ft_strmapi.c.73DD60A0D4B77283.idx b/.cache/clangd/index/ft_strmapi.c.73DD60A0D4B77283.idx new file mode 100644 index 0000000..a3cf625 Binary files /dev/null and b/.cache/clangd/index/ft_strmapi.c.73DD60A0D4B77283.idx differ diff --git a/.cache/clangd/index/ft_strncmp.c.130BC97847229322.idx b/.cache/clangd/index/ft_strncmp.c.130BC97847229322.idx new file mode 100644 index 0000000..db1efb6 Binary files /dev/null and b/.cache/clangd/index/ft_strncmp.c.130BC97847229322.idx differ diff --git a/.cache/clangd/index/ft_strnstr.c.36ECF862C023E04A.idx b/.cache/clangd/index/ft_strnstr.c.36ECF862C023E04A.idx new file mode 100644 index 0000000..567076c Binary files /dev/null and b/.cache/clangd/index/ft_strnstr.c.36ECF862C023E04A.idx differ diff --git a/.cache/clangd/index/ft_strrchr.c.E1F60C7C5D981483.idx b/.cache/clangd/index/ft_strrchr.c.E1F60C7C5D981483.idx new file mode 100644 index 0000000..b9ef1a2 Binary files /dev/null and b/.cache/clangd/index/ft_strrchr.c.E1F60C7C5D981483.idx differ diff --git a/.cache/clangd/index/ft_strtrim.c.5C1F726DF93A8E5D.idx b/.cache/clangd/index/ft_strtrim.c.5C1F726DF93A8E5D.idx new file mode 100644 index 0000000..54c499c Binary files /dev/null and b/.cache/clangd/index/ft_strtrim.c.5C1F726DF93A8E5D.idx differ diff --git a/.cache/clangd/index/ft_substr.c.0C3EC6A520E9C29F.idx b/.cache/clangd/index/ft_substr.c.0C3EC6A520E9C29F.idx new file mode 100644 index 0000000..4ab18e2 Binary files /dev/null and b/.cache/clangd/index/ft_substr.c.0C3EC6A520E9C29F.idx differ diff --git a/.cache/clangd/index/ft_tolower.c.BA903ED2E7E6EFAE.idx b/.cache/clangd/index/ft_tolower.c.BA903ED2E7E6EFAE.idx new file mode 100644 index 0000000..6fbb859 Binary files /dev/null and b/.cache/clangd/index/ft_tolower.c.BA903ED2E7E6EFAE.idx differ diff --git a/.cache/clangd/index/ft_toupper.c.750646D88D5B3BF3.idx b/.cache/clangd/index/ft_toupper.c.750646D88D5B3BF3.idx new file mode 100644 index 0000000..005a7f9 Binary files /dev/null and b/.cache/clangd/index/ft_toupper.c.750646D88D5B3BF3.idx differ diff --git a/.cache/clangd/index/game.c.B03695838049B596.idx b/.cache/clangd/index/game.c.B03695838049B596.idx new file mode 100644 index 0000000..4c41481 Binary files /dev/null and b/.cache/clangd/index/game.c.B03695838049B596.idx differ diff --git a/.cache/clangd/index/get_next_line.c.3CE3D9DE0FCBE423.idx b/.cache/clangd/index/get_next_line.c.3CE3D9DE0FCBE423.idx new file mode 100644 index 0000000..06f5ad9 Binary files /dev/null and b/.cache/clangd/index/get_next_line.c.3CE3D9DE0FCBE423.idx differ diff --git a/.cache/clangd/index/main.c.449FC24725B4900F.idx b/.cache/clangd/index/main.c.449FC24725B4900F.idx index c0d06a2..1f7aed8 100644 Binary files a/.cache/clangd/index/main.c.449FC24725B4900F.idx and b/.cache/clangd/index/main.c.449FC24725B4900F.idx differ diff --git a/.cache/clangd/index/print_board.c.12D2F1C84CA68F4B.idx b/.cache/clangd/index/print_board.c.12D2F1C84CA68F4B.idx new file mode 100644 index 0000000..aaf284d Binary files /dev/null and b/.cache/clangd/index/print_board.c.12D2F1C84CA68F4B.idx differ diff --git a/.cache/clangd/index/vector.c.CCEA61708CF10975.idx b/.cache/clangd/index/vector.c.CCEA61708CF10975.idx new file mode 100644 index 0000000..cf16e9d Binary files /dev/null and b/.cache/clangd/index/vector.c.CCEA61708CF10975.idx differ diff --git a/Makefile b/Makefile index 3b762f1..51fd717 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: lud-adam +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/07/18 12:51:21 by lud-adam #+# #+# # -# Updated: 2026/03/28 15:07:38 by lud-adam ### ########.fr # +# Updated: 2026/03/29 14:43:31 by lud-adam ### ########.fr # # # # **************************************************************************** # @@ -22,13 +22,15 @@ P_OBJ = .obj/ P_INC = inc/ P_LIBFT = libft/ -SRC = main.c \ - get_next_line.c \ - fill_array.c \ - check_input.c \ - print_board.c \ - ai.c \ - game.c +SRC = \ + main.c \ + get_next_line.c \ + fill_vector.c \ + check_input.c \ + print_board.c \ + ai.c \ + game.c \ + vector.c SRCS = $(addprefix $(P_SRC), $(SRC)) OBJS = $(patsubst $(P_SRC)%.c,$(P_OBJ)%.o,$(SRCS)) diff --git a/alum1 b/alum1 deleted file mode 100755 index 8cddbd2..0000000 Binary files a/alum1 and /dev/null differ diff --git a/compile_commands.json b/compile_commands.json index 3ecae3b..f14c52c 100644 --- a/compile_commands.json +++ b/compile_commands.json @@ -7,8 +7,8 @@ "-Wextra", "-Werror", "-MMD", - "-I", - "inc/", + "-Iinc/", + "-Ilibft/", "-c", "src/main.c", "-o", @@ -24,8 +24,8 @@ "-Wextra", "-Werror", "-MMD", - "-I", - "inc/", + "-Iinc/", + "-Ilibft/", "-c", "src/fill_array.c", "-o", @@ -41,13 +41,676 @@ "-Wextra", "-Werror", "-MMD", - "-I", - "inc/", + "-Iinc/", + "-Ilibft/", "-c", "src/check_input.c", "-o", ".obj/check_input.o" ], "file": "src/check_input.c" + }, + { + "directory": "/home/lud-adam/Documents/rush", + "arguments": [ + "cc", + "-Wall", + "-Wextra", + "-Werror", + "-MMD", + "-Iinc/", + "-Ilibft/", + "-c", + "src/get_next_line.c", + "-o", + ".obj/get_next_line.o" + ], + "file": "src/get_next_line.c" + }, + { + "directory": "/home/lud-adam/Documents/rush", + "arguments": [ + "cc", + "-Wall", + "-Wextra", + "-Werror", + "-MMD", + "-Iinc/", + "-Ilibft/", + "-c", + "src/print_board.c", + "-o", + ".obj/print_board.o" + ], + "file": "src/print_board.c" + }, + { + "directory": "/home/lud-adam/Documents/rush", + "arguments": [ + "cc", + "-Wall", + "-Wextra", + "-Werror", + "-MMD", + "-Iinc/", + "-Ilibft/", + "-c", + "src/ai.c", + "-o", + ".obj/ai.o" + ], + "file": "src/ai.c" + }, + { + "directory": "/home/lud-adam/Documents/rush", + "arguments": [ + "cc", + "-Wall", + "-Wextra", + "-Werror", + "-MMD", + "-Iinc/", + "-Ilibft/", + "-c", + "src/game.c", + "-o", + ".obj/game.o" + ], + "file": "src/game.c" + }, + { + "directory": "/home/lud-adam/Documents/rush", + "arguments": [ + "cc", + "-Wall", + "-Wextra", + "-Werror", + "-MMD", + "-Iinc/", + "-Ilibft/", + "-c", + "src/vector.c", + "-o", + ".obj/vector.o" + ], + "file": "src/vector.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_isdigit.o", + "-c", + "ft_isdigit.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_isdigit.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_isalpha.o", + "-c", + "ft_isalpha.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_isalpha.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_isalnum.o", + "-c", + "ft_isalnum.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_isalnum.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_isascii.o", + "-c", + "ft_isascii.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_isascii.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_isprint.o", + "-c", + "ft_isprint.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_isprint.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strlen.o", + "-c", + "ft_strlen.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strlen.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_memset.o", + "-c", + "ft_memset.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_memset.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_bzero.o", + "-c", + "ft_bzero.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_bzero.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_memcpy.o", + "-c", + "ft_memcpy.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_memcpy.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_memmove.o", + "-c", + "ft_memmove.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_memmove.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strlcpy.o", + "-c", + "ft_strlcpy.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strlcpy.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strlcat.o", + "-c", + "ft_strlcat.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strlcat.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_toupper.o", + "-c", + "ft_toupper.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_toupper.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_tolower.o", + "-c", + "ft_tolower.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_tolower.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strchr.o", + "-c", + "ft_strchr.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strchr.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strrchr.o", + "-c", + "ft_strrchr.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strrchr.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strncmp.o", + "-c", + "ft_strncmp.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strncmp.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_memcmp.o", + "-c", + "ft_memcmp.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_memcmp.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_memchr.o", + "-c", + "ft_memchr.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_memchr.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strnstr.o", + "-c", + "ft_strnstr.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strnstr.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_atoi.o", + "-c", + "ft_atoi.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_atoi.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_calloc.o", + "-c", + "ft_calloc.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_calloc.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strdup.o", + "-c", + "ft_strdup.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strdup.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_substr.o", + "-c", + "ft_substr.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_substr.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strjoin.o", + "-c", + "ft_strjoin.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strjoin.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strtrim.o", + "-c", + "ft_strtrim.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strtrim.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_split.o", + "-c", + "ft_split.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_split.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_itoa.o", + "-c", + "ft_itoa.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_itoa.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_strmapi.o", + "-c", + "ft_strmapi.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_strmapi.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_striteri.o", + "-c", + "ft_striteri.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_striteri.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_putchar_fd.o", + "-c", + "ft_putchar_fd.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_putchar_fd.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_putstr_fd.o", + "-c", + "ft_putstr_fd.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_putstr_fd.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_putendl_fd.o", + "-c", + "ft_putendl_fd.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_putendl_fd.c" + }, + { + "directory": "/home/lud-adam/Documents/rush/libft", + "arguments": [ + "cc", + "-MMD", + "-MP", + "-o", + "ft_putnbr_fd.o", + "-c", + "ft_putnbr_fd.c", + "-Wall", + "-Wextra", + "-Werror", + "-Ilibft.h" + ], + "file": "ft_putnbr_fd.c" } ] diff --git a/inc/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx b/inc/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx new file mode 100644 index 0000000..08856db Binary files /dev/null and b/inc/.cache/clangd/index/alcu.h.FC2EE915F1165072.idx differ diff --git a/inc/.cache/clangd/index/get_next_line.h.01BAFD108BBB5F61.idx b/inc/.cache/clangd/index/get_next_line.h.01BAFD108BBB5F61.idx new file mode 100644 index 0000000..526de41 Binary files /dev/null and b/inc/.cache/clangd/index/get_next_line.h.01BAFD108BBB5F61.idx differ diff --git a/inc/.cache/clangd/index/vector.h.9C0A9CF7FEC6535B.idx b/inc/.cache/clangd/index/vector.h.9C0A9CF7FEC6535B.idx new file mode 100644 index 0000000..31f6966 Binary files /dev/null and b/inc/.cache/clangd/index/vector.h.9C0A9CF7FEC6535B.idx differ diff --git a/inc/alcu.h b/inc/alcu.h index 11a7228..d116296 100644 --- a/inc/alcu.h +++ b/inc/alcu.h @@ -6,20 +6,24 @@ /* By: lud-adam +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/28 13:27:29 by lud-adam #+# #+# */ -/* Updated: 2026/03/28 21:41:55 by dgaillet ### ########lyon.fr */ +/* Updated: 2026/03/29 14:58:00 by lud-adam ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef ALCU_H # define ALCU_H -# include +#include "vector.h" -char *read_file(int fd); -int check_input(int fd); -void print_board(int *game_state, size_t nb_line); -int *fill_array(int fd, int size); +#include +#include + +char *read_file(int fd); +bool check_input(t_vector* lines); +void print_board(int *game_state, size_t nb_line); +bool fill_vector(t_vector* lines, int fd); int ai(int *gamestate, int nb_line); -void game(int *lines, int size); +void game(int *lines, int size); +int* fill_array(t_vector* lines, int* size); #endif diff --git a/inc/compile_commands.json b/inc/compile_commands.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/inc/compile_commands.json @@ -0,0 +1 @@ +[] diff --git a/inc/vector.h b/inc/vector.h new file mode 100644 index 0000000..e0118ee --- /dev/null +++ b/inc/vector.h @@ -0,0 +1,46 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* vector.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lud-adam +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/29 14:24:01 by lud-adam #+# #+# */ +/* Updated: 2026/03/29 14:40:21 by lud-adam ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef VECTOR_H +# define VECTOR_H + +#define VECTOR_INIT_CAPACITY 6 +#define UNDEFINE -1 +#define SUCCESS 0 + +#define VECTOR_INIT(vec) t_vector vec;\ + vector_init(&vec) + +typedef struct s_vector_list +{ + void **items; + int capacity; + int total; +} t_vector_list; + +typedef struct s_vector t_vector; + +struct s_vector +{ + t_vector_list vector_list; /**< List to store vector elements */ + int (*pfVectorTotal)(t_vector *); /**< Retrieves the total number of elements in the vector */ + int (*pfVectorResize)(t_vector *, int); /**< Resizes the vector to a new capacity */ + int (*pfVectorAdd)(t_vector *, void *); /**< Adds an element to the vector */ + int (*pfVectorSet)(t_vector *, int, void *); /**< Sets an element at a specific index in the vector */ + void *(*pfVectorGet)(t_vector *, int); /**< Retrieves an element from the vector */ + int (*pfVectorDelete)(t_vector *, int); /**< Deletes an element from the vector */ + int (*pfVectorFree)(t_vector *); /**< Frees the memory allocated for the vector */ +}; + +void vector_init(t_vector* v); + +#endif diff --git a/src/check_input.c b/src/check_input.c index f25aa80..18516cb 100644 --- a/src/check_input.c +++ b/src/check_input.c @@ -12,30 +12,31 @@ #include "../libft/libft.h" #include "get_next_line.h" +#include "vector.h" + #include #include #include +#include -int check_input(int fd) +bool check_input(t_vector* lines) { int i; int j; - char *line; + char* line; - line = NULL; - line = get_next_line(fd); j = 0; - while (line != NULL) + line = NULL; + while (j < lines->pfVectorTotal(lines)) { + line = (char*)lines->pfVectorGet(lines, j); i = -1; while (line[++i]) if (!(line[i] >= '0' && line[i] <= '9') && line[i] != '\n') - return (free(line), -1); + return (false); if (ft_atoi(line) < 1 || ft_atoi(line) > 10000) - return (free(line), -1); - free(line); + return (false); j++; - line = get_next_line(fd); } - return (j); + return (true); } diff --git a/src/fill_array.c b/src/fill_vector.c similarity index 66% rename from src/fill_array.c rename to src/fill_vector.c index 90b2a21..13666f5 100644 --- a/src/fill_array.c +++ b/src/fill_vector.c @@ -1,35 +1,51 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* fill_array.c :+: :+: :+: */ +/* fill_vector.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lud-adam +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/28 13:21:46 by lud-adam #+# #+# */ -/* Updated: 2026/03/28 20:53:02 by dgaillet ### ########lyon.fr */ +/* Updated: 2026/03/29 14:58:09 by lud-adam ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft/libft.h" + #include "get_next_line.h" -int *fill_array(int fd, int size) -{ - int *res; - char *line; - int i; +#include "alcu.h" + +bool fill_vector(t_vector* lines, int fd) +{ + char *line; - res = malloc(sizeof(int) * size); - if (res == NULL) - return (NULL); line = get_next_line(fd); - i = 0; while (line != NULL) { + lines->pfVectorAdd(lines, line); + line = get_next_line(fd); + } + return (true); +} + +int* fill_array(t_vector* lines, int* size) +{ + int* res; + int i; + char* line; + + i = 0; + line = NULL; + *size = lines->pfVectorTotal(lines); + res = malloc(sizeof(int) * *size); + if (!res) + return (NULL); + while (i < *size) + { + line = (char*)lines->pfVectorGet(lines, i); res[i] = ft_atoi(line); i++; - free(line); - line = get_next_line(fd); } return (res); } diff --git a/src/game.c b/src/game.c index 9ef9f52..b517dbf 100644 --- a/src/game.c +++ b/src/game.c @@ -69,6 +69,8 @@ static void player_turn(int *line) if (temp) free(temp); } + if (temp) + free(temp); } static void play_turns(int *lines, int i, int *ai_turn, int size) diff --git a/src/main.c b/src/main.c index fc17d34..3ff6c79 100644 --- a/src/main.c +++ b/src/main.c @@ -6,14 +6,14 @@ /* By: lud-adam +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/28 12:30:29 by lud-adam #+# #+# */ -/* Updated: 2026/03/28 21:41:29 by dgaillet ### ########lyon.fr */ +/* Updated: 2026/03/29 14:58:10 by lud-adam ### ########.fr */ /* */ /* ************************************************************************** */ #include "../libft/libft.h" #include "alcu.h" + #include -#include #include static int get_fd(int argc, char **argv) @@ -32,27 +32,38 @@ int main(int argc, char *argv[]) { int fd; int size; - int *lines; + int* lines_int; + VECTOR_INIT(lines); fd = get_fd(argc, argv); + lines_int = NULL; + size = 0; if (fd < 0) { ft_putstr_fd("ERROR", 2); return (1); } - size = check_input(fd); - if (size < 0) + fill_vector(&lines, fd); + if (check_input(&lines) == false) { + lines.pfVectorFree(&lines); + ft_putstr_fd("ERROR", 2); + return (1); + + } + if (argc == 1) + fd = open("/dev/tty", O_RDONLY); + // // fd = get_fd(argc, argv); + lines_int = fill_array(&lines, &size); + if (!lines_int) + { + lines.pfVectorFree(&lines); ft_putstr_fd("ERROR", 2); return (1); } + game(lines_int, size); close(fd); - fd = open(argv[1], O_RDONLY); - lines = fill_array(fd, size); - if (!lines) - return (1); - game(lines, size); - close(fd); - free(lines); + free(lines_int); + lines.pfVectorFree(&lines); return (0); } diff --git a/src/vector.c b/src/vector.c new file mode 100644 index 0000000..ef4bc91 --- /dev/null +++ b/src/vector.c @@ -0,0 +1,159 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* vector.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lud-adam +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/03/29 14:23:01 by lud-adam #+# #+# */ +/* Updated: 2026/03/29 14:50:19 by lud-adam ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "vector.h" +#include "libft.h" +#include + +int vectorResize(t_vector *v, int capacity); +int vectorPushBack(t_vector *v, void *item); +int vectorSet(t_vector *v, int index, void *item); +void *vectorGet(t_vector *v, int index); +int vectorDelete(t_vector *v, int index); +int vectorFree(t_vector *v); +int vectorTotal(t_vector *v); + +void vector_init(t_vector *v) +{ + // Initialize function pointers + v->pfVectorTotal = vectorTotal; + v->pfVectorResize = vectorResize; + v->pfVectorAdd = vectorPushBack; + v->pfVectorSet = vectorSet; + v->pfVectorGet = vectorGet; + v->pfVectorFree = vectorFree; + v->pfVectorDelete = vectorDelete; + // Allocate memory and check for failure + v->vector_list.capacity = VECTOR_INIT_CAPACITY; + v->vector_list.total = 0; + v->vector_list.items = malloc(sizeof(void *) * v->vector_list.capacity); + if (!v->vector_list.items) + { + ft_putstr_fd("Memory allocation failed in vector_init\n", 2); + exit(EXIT_FAILURE); + } +} + +int vectorTotal(t_vector *v) +{ + int totalCount = UNDEFINE; + if(v) + { + totalCount = v->vector_list.total; + } + return totalCount; +} + +int vectorResize(t_vector *v, int capacity) +{ + int status = UNDEFINE; + if(v) + { + void **items = realloc(v->vector_list.items, sizeof(void *) * capacity); + if (items) + { + v->vector_list.items = items; + v->vector_list.capacity = capacity; + status = SUCCESS; + } + } + return status; +} + +int vectorPushBack(t_vector *v, void *item) +{ + int status = UNDEFINE; + if(v) + { + if (v->vector_list.capacity == v->vector_list.total) + { + status = vectorResize(v, v->vector_list.capacity * 2); + if(status != UNDEFINE) + { + v->vector_list.items[v->vector_list.total++] = item; + } + } + else + { + v->vector_list.items[v->vector_list.total++] = item; + status = SUCCESS; + } + } + return status; +} + +int vectorSet(t_vector *v, int index, void *item) +{ + int status = UNDEFINE; + if(v) + { + if ((index >= 0) && (index < v->vector_list.total)) + { + v->vector_list.items[index] = item; + status = SUCCESS; + } + } + return status; +} + +void *vectorGet(t_vector *v, int index) +{ + void *readData = NULL; + if(v) + { + if ((index >= 0) && (index < v->vector_list.total)) + { + readData = v->vector_list.items[index]; + } + } + return readData; +} + +int vectorDelete(t_vector *v, int index) +{ + int status = UNDEFINE; + int i = 0; + if(v) + { + if ((index < 0) || (index >= v->vector_list.total)) + return status; + v->vector_list.items[index] = NULL; + for (i = index; (i < v->vector_list.total - 1); ++i) + { + v->vector_list.items[i] = v->vector_list.items[i + 1]; + v->vector_list.items[i + 1] = NULL; + } + v->vector_list.total--; + if ((v->vector_list.total > 0) && ((v->vector_list.total) == (v->vector_list.capacity / 4))) + { + vectorResize(v, v->vector_list.capacity / 2); + } + status = SUCCESS; + } + return status; +} + +int vectorFree(t_vector *v) +{ + int status = UNDEFINE; + int total = v->pfVectorTotal(v); + if(v) + { + for (int i = 0; i < total; i++) + { + void * temp = v->pfVectorGet(v, i); + free (temp); + } + free(v->vector_list.items); + } + return status; +}