Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
._.*
.DS*
._DS*
*.dSYM
*.dSYM*
.nfs*
*.a
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# By: tcherret <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/02/07 12:35:44 by tcherret #+# #+# #
# Updated: 2019/03/03 15:54:21 by tcherret ### ########.fr #
# Updated: 2019/03/16 10:20:17 by tcherret ### ########.fr #
# #
# **************************************************************************** #

Expand All @@ -16,7 +16,7 @@ NAMELIB = ./libft/libftprintf.a

CC = @gcc

CFLAGS =-Wall -Wextra -Werror -g #-fsanitize=undefined #-fsanitize=undefined
CFLAGS =-Wall -Wextra -Werror -g

SRCS = srcs/lem_in.c\
srcs/parsing0.c\
Expand Down
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
# 42-Lem-in
<div style="text-align:center">
<img src="resources/bonk.gif" width = "100%" alt = "admit you love this"/>
</div>

<h1 style="text-align: center;" markdown="1">Lem-in</h1>

*****

## DISCLAIMER

Jupyter Notebook was mainly used for **visualization** purposes as a side objective. The core language used is in C.

## In World Practice Inspiration

[Slime Mold Networks Just Like Tokyo Rail System](https://www.wired.com/2010/01/slime-mold-grows-network-just-like-tokyo-rail-system/)

## Building

`make && pip3 install -r requirements.txt`
`./lem_in [-p] [-c] < maps/your_choice_of_map`

> **-p** Lists of used paths that the ants are being sent.
>
> **-c** Count the total of turns it took the total traversal of the map from source to exit.

## Running the program
After selecting the map of your choice from the `maps` folder, you will see different files with bunch of things happening.

To understand what is it doing, I will describe each part of the map file that is being used:

`~/small/ex.map`

```
3 <- Number of ants placed
2 5 0 <- Creating a new room
##start <- Command call of the start room
0 1 2 <- Start room of all ants first placed
##end <- Command call of the end room
1 9 2 <- Exit room of all ants in the end
3 5 4 <- Creating a new room
0-2 <- Room name 0 creating a path to room name 2
0-3 <- Room name 0 creating a path to room name 3
2-1 <- Room name 2 creating a path to room name 1
3-1 <- Room name 3 creating a path to room name 1
2-3 <- Room name 2 creating a path to room name 3
```

The first line of the file will be **ALWAYS** the total number of ants in place. After that, you can start creating more rooms. In order to create a new room, the structure must be `[room string name] [position x] [position y]`. For example, `2 5 0` is a room with a name `2` located in `5` and `0`. Once the rooms are created (including the start and end), we can link to each room to create a path for our ants such as `0-2`, `0-3`, etc...

## Demo

<div style="text-align:center">
<img src="resources/demo.gif" width = "100%" alt = "admit you love this"/>
</div>

And for the big map from the `visual/ex.txt` example:

<div style="text-align:center">
<img src="resources/biboi.png" width = "100%" alt = "admit you love this"/>
</div>
86 changes: 0 additions & 86 deletions get_next_line.c

This file was deleted.

20 changes: 16 additions & 4 deletions includes/lem_in.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* lem_in.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tcherret <marvin@42.fr> +#+ +:+ +#+ */
/* By: tcherret <tcherret@student.42.us.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/19 22:31:09 by tcherret #+# #+# */
/* Updated: 2019/03/03 17:59:15 by tcherret ### ########.fr */
/* Updated: 2019/04/03 16:08:12 by ztisnes ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,6 +17,16 @@
# include <stdlib.h>
# include <unistd.h>
# define SIZE 256
# define COLOR_RESET "\033[0m"
# define BOLD "\033[1m"
# define BLACK_TEXT "\033[30;1m"
# define RED_TEXT "\033[31;1m"
# define GREEN_TEXT "\033[32;1m"
# define YELLOW_TEXT "\033[33;1m"
# define BLUE_TEXT "\033[34;1m"
# define MAGENTA_TEXT "\033[35;1m"
# define CYAN_TEXT "\033[36;1m"
# define WHITE_TEXT "\033[37;1m"

/*
** Data structures to stock the information
Expand All @@ -40,7 +50,8 @@ typedef struct s_path
{
int *path;
int weight;
int ants_send;
int c_weight;
int ants_to_send;
} t_path;

typedef struct s_farm
Expand Down Expand Up @@ -104,6 +115,7 @@ void put_vertex_visited(int ind, t_farm *farm);
int check_enqueue(int *queue, int i, t_farm *farm);
void create_path(int **path, int *queue, t_farm *farm, int nb);
int path_found(t_farm *farm, int **queue, int end, int vertex);
int check_duplicate_path(t_farm *farm, int vertex);

/*
** Functions to move the ants, to check the room and to display
Expand All @@ -113,6 +125,6 @@ int moving_display(t_farm *farm);
int move_ant(t_room *src, t_room *dst, t_farm *farm);
int check_room_free(t_room *room);
int graph_finished(t_farm *farm);
void print_path(int *path, int nb);
void print_path(int *path, int nb, t_farm *farm);

#endif
20 changes: 0 additions & 20 deletions lem_in.dSYM/Contents/Info.plist

This file was deleted.

Binary file removed lem_in.dSYM/Contents/Resources/DWARF/lem_in
Binary file not shown.
File renamed without changes.
Loading