Ejemplo n.º 1
0
int main(void) {
    struct map map;
    int i;

    srand((unsigned int)time(NULL));
    printf("** zDemineur **\n\n");
    if(!load(&map))
        fill_map(&map);

    map_gen(&map);

    while(!iswon(&map)) {
#if defined (_WIN32) || defined (_WIN64)
        system("cls");
#else
        printf("________________________________________________________\n");
#endif
        display_map(&map);
        action(&map);
    }
    printf("\nYou won ! Here is the completely visible map :\n");
    display_map_debug(&map);

    for(i = 0; i < map.rows; ++i)
        free(map.Map[i]);

    free(map.Map);
    return 0;
}
Ejemplo n.º 2
0
int			main(int argc, char **argv)
{
	t_struck			s;
	t_pc				*proc;
	unsigned long long	i[3];

	if (argc == 1)
		ft_usage();
	init_struct(&s);
	proc = NULL;
	check_valid_file(&s, argv, 0);
	map_gen(&s, &proc, -1, i);
	s.pro = &proc;
	if (s.rep & GRAPH)
	{
		init_graph(&s);
		mlx_hook(s.img.win, 2, (1l << 0), key_functions, &s);
		mlx_hook(s.img.menu, 2, (1l << 0), key_functions, &s);
		s.rep ^= STOP;
		mlx_loop_hook(s.img.mlx, aff_graph, &s);
		mlx_loop(s.img.mlx);
	}
	else
		launching_vm(&s);
	return (0);
}
Ejemplo n.º 3
0
struct map_t *map_preset_sand(void)
{
        struct map_t *sandmap;
        double **sand;
        int i;
        int j;

        sand = empty_simplex_matrix(LINES, COLS);

        for (i=0; i<LINES; i++) {
        for (j=0; j<COLS; j++) {
                sand[i][j] = BEACH_F;
        }
        }

        sandmap = new_map(FULLSCREEN);
        map_gen(sandmap, sandmap->pmap, MAP_NOSMOOTH);

        /*sandmap->asset[1] = new_asset(0);*/
        /*sandmap->asset[1]->put(sandmap, 1, ((LINES/2)-(LINES/3)), ((COLS/2)-2));*/

        map_render(sandmap);

        return sandmap;
}
Ejemplo n.º 4
0
struct map_t *map_preset_arena(void)
{
        struct map_t *arena;
        struct map_t *cave;
        double **armap;
        int i;
        int j;

        armap = empty_simplex_matrix(FULLSCREEN);
       
        for (i=0; i<LINES; i++) {
        for (j=0; j<COLS; j++) {
                if (i >= ARENA_H/2 && i <= LINES-ARENA_H/2
                &&  j >= ARENA_W/2 && j <= COLS-ARENA_W/2)
                        armap[i][j] = BEACH_F;
                else if (i > ISLAND_H_LO && i < ISLAND_H_HI 
                &&       j > ISLAND_W_LO-2 && j < ISLAND_W_HI)
                {
                        if (i > ISLAND_H_LO+ISLAND_FAT+5
                        &&  i < ISLAND_H_HI-ISLAND_FAT
                        &&  j < ISLAND_W_LO+ISLAND_FAT+1) {
                                if (j > ISLAND_W_LO+ISLAND_FAT-2)
                                        armap[i][j] = BEACH_F;
                                else
                                        armap[i][j] = -0.05;
                        } else {
                                armap[i][j] = TERRA_F;
                        }
                }
                else
                        armap[i][j] = -0.05;
        }
        }
       
        arena = new_map(FULLSCREEN);
        map_gen(arena, armap, MAP_NOSMOOTH);

        /* Make a cave entrance */
        cave = new_dungeon();
        put_door(CAVE_DOOR, arena, cave, 
                 1, 1, ARENA_H/2-1, COLS/2,
                 1, 1, LINES/2-10, COLS/2);

        cave_connect_door(cave);
        map_render(arena);
        map_render(cave);

        return arena;
}
void create_node_map(int n_shader, int n_mem, int size, int use_map) 
{
   node_map = (int*)malloc((size)*sizeof(int));   
   if (use_map) {
      switch (size) {
      case 16 :
         { // good for 8 shaders and 8 memory cores
            int newmap[]  = {  
               0, 2, 5, 7,
               8,10,13,15,
               1, 3, 4, 6, //memory nodes
               9,11,12,14   //memory nodes
            }; 
            memcpy (node_map, newmap,16*sizeof(int));
            break;
         }
      case 64:
         { // good for 56 shaders and 8 memory cores
            int newmap[]  = {  
               0,  1,  2,  4,  5,  6,  7,  8,
               9, 10, 11, 12, 13, 14, 16, 18,
               19, 20, 21, 22, 23, 24, 25, 26,
               27, 28, 30, 31, 32, 33, 34, 35,
               37, 38, 39, 40, 41, 42, 43, 44,                    
               45, 46, 48, 50, 51, 52, 53, 54,
               55, 56, 57, 58, 59, 60, 62, 63, 
               3, 15, 17, 29, 36, 47, 49, 61  //memory nodes are in this line
            }; 
            memcpy (node_map, newmap,64*sizeof(int));
            break;
         }
      case 121:
         { // good for 110 shaders and 11 memory cores
            int newmap[]  = {  
               0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10,
               11, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23,
               24, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36,
               37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
               48, 49, 50, 51, 52, 53, 54, 55, 56, 58, 59,
               61, 62, 64, 65, 66, 67, 68, 69, 70, 71, 72,
               73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
               84, 85, 86, 87, 88, 89, 90, 91, 93, 94, 96,
               97, 98, 99,101,102,103,104,105,106,107,109,
               110,111,112,113,114,115,116,117,118,119,120,  
               12, 20, 25, 28, 57, 60, 63, 92, 95,100,108 //memory nodes are in this line
            }; 
            memcpy (node_map, newmap,121*sizeof(int));
            break;
         }
      case 36:
         {
            int memnodes[8]={3,7,10,12,23,25,28,32};
            map_gen(6/*dim*/,8/*memcount*/,memnodes);
            break;
         }
      default: 
         {
            cout<<"WARNING !!! NO MAPPING IMPLEMENTED YET FOR THIS CONFIG"<<endl;
            for (int i=0;i<size;i++) {
               node_map[i]=i;
            }
         }
      }
   } else { // !use_map
      for (int i=0;i<size;i++) {
         node_map[i]=i;
      }
   }
   reverse_map = (int*)malloc((size)*sizeof(int));   
   for (int i = 0; i < size ; i++) {
      for (int j = 0; j<size ; j++) {
         if (node_map[j]==i) {
            reverse_map[i]=j;
            break;
         }
      }
   }
   printf("GPGPU-Sim uArch: interconnect nodemap\n");
   display_map((int) sqrt(size),size);

}