diff --git a/fourmi/fourmi.c b/fourmi/fourmi.c index 2189dc721b3f8046aba5632828a2470582ab9768..462f51984d647bdbfdb523de9e436a8066962a95 100644 --- a/fourmi/fourmi.c +++ b/fourmi/fourmi.c @@ -7,6 +7,7 @@ frmi create_fourmi(int nb_sommet) fr->path = malloc(sizeof(stack)); stack_init(fr->path, nb_sommet); fr->distance = 0; + fr->ttl = nb_sommet; return fr; } diff --git a/fourmi/fourmi.h b/fourmi/fourmi.h index 140b2d301fb483ba0083fe1450927c06163b03cc..5f2ec1e5f7a9903ce57dba87a76b61f3a084bd4b 100644 --- a/fourmi/fourmi.h +++ b/fourmi/fourmi.h @@ -14,6 +14,7 @@ typedef struct _fourmi stack *path; int distance; //stocke la distane parcourue par la fourmi int depose_pheromone; //permet d'activer le dépôt de phéromones + int ttl; }f; typedef f *frmi; diff --git a/graphe/graphe.c b/graphe/graphe.c index 0a9648a5d7d04604bd60a7964c9691055cbcfb3e..e85393bce558d5515fb5f5ac5ec4f80efaf96876 100644 --- a/graphe/graphe.c +++ b/graphe/graphe.c @@ -236,7 +236,8 @@ void create_graph_vis(graph g) void shortest_path(graph g, frmi f, int noeud) { - if (noeud == g->nourriture) + f->ttl--; + if (noeud == g->nourriture || f->ttl == 0) { stack_push(f->path, noeud); return; diff --git a/le_plus_court_chemin.txt b/le_plus_court_chemin.txt index 8071ff10caef46d5cc988511d709e95a97b8fb11..c6aeb1963c34728b289d10899ed9d2735c0823cc 100644 --- a/le_plus_court_chemin.txt +++ b/le_plus_court_chemin.txt @@ -1 +1 @@ -the shortest path is [0][1][3][7] with a cost of 8 +the shortest path is \ No newline at end of file diff --git a/tp_fourmi b/tp_fourmi index d17ce93c5315f4c3094f59e6faf87ceec5994e74..82c056cc98098eba2fe0510d0e5444c0d9c8cf89 100755 Binary files a/tp_fourmi and b/tp_fourmi differ