Commit 52010a1b authored by Valentin MEUNIER's avatar Valentin MEUNIER
Browse files

le

parent a5b58682
......@@ -10,7 +10,7 @@ int max(int a, int b)
int distance_euclidienne(int a, int b)
{
return (int) sqrt((a/P - b/b)*(a/P - b/P) + (a%P -b%P)*(a%P -b%P));
return (int) sqrt((a/P - b/P)*(a/P - b/P) + (a%P -b%P)*(a%P -b%P));
}
int distance_tcheby(int a, int b)
......@@ -79,6 +79,7 @@ int * dijsktra(int ** laby, int noeuds, int depart)
if (distance[voisin[j]].poids>1+distance[sommet].poids)
{
distance[voisin[j]].poids=1 + distance[sommet].poids;
tas->tab[indice_valeur[voisin[j]]].poids=distance[voisin[j]].poids;
percolation_bas_tas_min(tas,indice_valeur[voisin[j]],indice_valeur);
parent[voisin[j]]=sommet;
}
......@@ -162,6 +163,7 @@ int * Aetoile_euclidienne(int ** laby, int noeuds, int depart, int arrivee)
if (distance[voisin[j]].poids>(1+distance[sommet].poids+ distance_euclidienne(voisin[j],arrivee)))
{
distance[voisin[j]].poids=1 + distance[sommet].poids+ distance_euclidienne(voisin[j],arrivee);
tas->tab[indice_valeur[voisin[j]]].poids=distance[voisin[j]].poids;
percolation_bas_tas_min(tas,indice_valeur[voisin[j]],indice_valeur);
parent[voisin[j]]=sommet;
}
......@@ -246,6 +248,7 @@ int * Aetoile_tcheby(int ** laby, int noeuds, int depart,int arrivee)
if (distance[voisin[j]].poids>1+distance[sommet].poids+ distance_tcheby(voisin[j],arrivee))
{
distance[voisin[j]].poids=1 + distance[sommet].poids+ distance_tcheby(voisin[j],arrivee);
tas->tab[indice_valeur[voisin[j]]].poids=distance[voisin[j]].poids;
percolation_bas_tas_min(tas,indice_valeur[voisin[j]],indice_valeur);
parent[voisin[j]]=sommet;
}
......@@ -330,6 +333,7 @@ int * Aetoile_manhattan(int ** laby, int noeuds, int depart, int arrivee)
if (distance[voisin[j]].poids>1+distance[sommet].poids+ distance_manhattan(voisin[j],arrivee))
{
distance[voisin[j]].poids=1 + distance[sommet].poids+ distance_manhattan(voisin[j],arrivee);
tas->tab[indice_valeur[voisin[j]]].poids=distance[voisin[j]].poids;
percolation_bas_tas_min(tas,indice_valeur[voisin[j]],indice_valeur);
parent[voisin[j]]=sommet;
}
......@@ -376,39 +380,41 @@ int main (int argc, char** argv)
graph=kruskal(graph,noeuds,nb_aretes,&cours,p);
tab=tableau_ligne(graph,cours);
affiche_graph_couple(gr
int depart=rand()%noeuds;
int arrivee=rand()%noeuds;
clock_t t_depart, t_fin;
float temps;
long temps;
t_depart=clock();
// for (int i=0; i<1000; i++)
parent=dijsktra(tab,noeuds,arrivee);
t_fin=clock();
temps=-t_depart+t_fin;
printf("temps dijsktra : %f\n",temps);
printf("temps dijsktra : %ld\n",temps);
t_depart=clock();
// for (int i=0; i<1000; i++)
parent=Aetoile_euclidienne(tab,noeuds,depart,arrivee);
t_fin=clock();
temps=-t_depart+t_fin;
printf("temps Aetoile_euclidienne : %f\n",temps);
printf("temps Aetoile_euclidienne : %ld\n",temps);
t_depart=clock();
// for (int i=0; i<1000; i++)
parent=Aetoile_tcheby(tab,noeuds,depart,arrivee);
t_fin=clock();
temps=-t_depart+t_fin;
printf("temps Aetoile_tcheby : %f\n",temps);
printf("temps Aetoile_tcheby : %ld\n",temps);
t_depart=clock();
// for (int i=0; i<1000; i++)
parent=Aetoile_manhattan(tab,noeuds,depart,arrivee);
t_fin=clock();
temps=-t_depart+t_fin;
printf("temps Aetoile_manhattan: %f\n",temps);
printf("temps Aetoile_manhattan: %ld\n",temps);
}
......@@ -178,3 +178,10 @@ void afficherImage(SDL_Renderer *renderer,SDL_Window *window,int **tab,int taill
}
}
void peindreMap(SDL_Texture * texture, SDL_Window* window ,SDL_Renderer *renderer, int noeuds, int taille_cell, int ** laby)
{
printf("peindre case %d %d %d \n",noeuds%P,noeuds/P,laby[noeuds%P][noeuds/P]);
affichage_texture(texture,window, renderer, laby[noeuds%P][noeuds/P], noeuds%P, noeuds/P, taille_cell);
}
......@@ -5,5 +5,6 @@ SDL_Texture* load_texture_from_image(char * file_image_name, SDL_Renderer *ren
void affichage_texture(SDL_Texture *my_texture,SDL_Window *window,SDL_Renderer *renderer,int x,int coord_colonne,int coord_ligne,int taille_cell);
void afficherImage(SDL_Renderer *renderer,SDL_Window *window,int **tab,int taille_cell,SDL_Texture* texture);
void affichage_fin(SDL_Texture *my_texture,SDL_Window *window,SDL_Renderer *renderer,int coord_colonne,int coord_ligne,int taille_cell);
void peindreMap(SDL_Texture * texture, SDL_Window* window ,SDL_Renderer *renderer, int noeuds, int taille_cell, int ** laby);
#endif
......@@ -4,8 +4,8 @@
#include "tas.h"
#include "graph_aretes_tab.h"
#define N 13
#define P 15
#define N 93
#define P 95
graph_t * kruskal(graph_t * graph,int noeuds, int nb_aretes,int * cours,double p);
......
This diff is collapsed.
......@@ -6,24 +6,25 @@
#include<SDL2/SDL.h>
#include "kruskal.h"
#include <math.h>
#include "affichage_image.h"
#include "dijsktra.h"
#include "texture_perso.h"
#include "colision.h"
#include "DFS.h"
#include "affichage_image.h"
#include <math.h>
typedef enum {
FLAG_N=1,
FLAG_S=2,
FLAG_E=4,
FLAG_O=8
}flag_t;
void end_sdl(char ok,char const* msg,SDL_Window* window, SDL_Renderer* renderer);
void afficheEcranIntelligement(SDL_Renderer*,int**,int);
void chemin(SDL_Renderer *,int, int, int, int *);
void peindreDFS(SDL_Renderer * , int, int);
int min(int , int);
int main(int ,char**);
typedef enum {
FLAG_N = 1,
FLAG_S = 2,
FLAG_E = 4,
FLAG_O = 8
}flag_t;
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment