Example #1
0
/**
 * \fn struct graphe* init_graphe()
 * \brief Fonction Initialisant un graphe
 *
 * \return graphe Pointeur vers le graphe qui vient d'être initialisé.
 */
struct graphe* init_graphe()
{
  int i,j;
  struct graphe* graphe = malloc(sizeof(struct graphe));
  for(i=0;i<NB_SOMMETS;i++)
  {
    struct sommets* champ = init_sommet();
    struct sommets* route = init_sommet();
    struct sommets* ville = init_sommet();
    graphe->champs[i] = champ;
    graphe->routes[i] = route;
    graphe->villes[i] = ville;
  }
  for(i=0;i<NB_SOMMETS;i++)
  {
    for(j=0;j<NB_SOMMETS;j++)
    {
      graphe->mat_champs[i][j] = 0;
      graphe->mat_routes[i][j] = 0;
      graphe->mat_villes[i][j] = 0;
    }
  }
  graphe->monaster = 0;
  graphe->pion_monaster = 0;
  
  return graphe;
}
Example #2
0
Tpoint* genere_sommet(Image*  i)
{
	double x = rand()/ (double) RAND_MAX; 	// la division par rand_max ramene le nombre entre 0 et 1
	double y = rand()/ (double) RAND_MAX;
	double z;
	// on évite que les valeurs générées soient sur les bords de la map
	if(x == 0)
		x = 0.00001;
	if(x == 1)
		x = 0.99999;
	if(y == 0)
		x = 0.00001;
	if(y == 1)
		x = 0.99999;
	// reste à générer le point d'altitude
	z = genere_altitude(i, x, y);
	return init_sommet(x, y, 0.); 
	
}