Exemple #1
0
int		main(int argc, char **argv)
{
	t_fillit	*linear;
	t_info		l;
	char		*map;

	if (argc != 2)
	{
		write(1, "usage: ./fillit file\n", 21);
		return (0);
	}
	if (!check(argv[1]) || open(argv[1], O_RDONLY) == -1)
	{
		write(1, "error\n", 6);
		return (0);
	}
	linear = full_it(argv[1], &l);
	min_map(&l);
	map = generate_map(l.min);
	while (resolve(&linear, &l, &map) != 1)
	{
		l.min++;
		ft_strdel(&map);
		map = generate_map((&l)->min);
	}
	return (0);
}
Exemple #2
0
void MultisphereParallel::restart(double *list)
{
    bool dummy = false;
    int m = 0, nrecv_this;

    int nbody_all_old = static_cast<int> (list[m++]);

    nbody_ = nbody_all_ = 0;

    for(int i = 0; i < nbody_all_old; i++)
    {
        nrecv_this = static_cast<int>(list[m]);
        
        double *x_bnd = &(list[m+1]);
        
        if(domain->is_in_subdomain(x_bnd))
        {
            
            customValues_.addZeroElement();
            customValues_.deleteRestartElement(nbody_,dummy,dummy,dummy);
            customValues_.popElemFromBuffer(&(list[m+4]),OPERATION_RESTART,dummy,dummy,dummy);

            nbody_++;
        }
        m += nrecv_this;
    }

    // do initialization tasks

    MPI_Sum_Scalar(nbody_,nbody_all_,world);
    generate_map();
    reset_forces(true);

}
Exemple #3
0
void		reset_game(void)
{
  t_link	*l;
  t_users	*u;
  int		seed;

  printf("Team %s won!\n", g_info.winner->name);
  lookup(g_info.users, graphics_seg(g_info.winner->name), &notify_graphic);
  while ((l = lookup_and_pop(g_info.users, NULL, &find_player)) != NULL)
    {
      u = (t_users*)l->ptr;
      u->team->free_slots = g_info.world.clients_per_team;
      u->team->nb_max_lvl = 0;
      lookup(g_info.users, graphics_pdi(u), &notify_graphic);
      delete_link(l, &free_users);
    }
  free_map(g_info.map);
  if (g_info.world.seed_spec == true)
    seed = g_info.world.seed;
  else
    seed = time(NULL);
  if ((g_info.map = generate_map(g_info.world.x, g_info.world.y, seed)) == NULL)
    leave("Failed to generate map");
  g_info.winner = NULL;
  g_info.end_game = false;
  log_msg(stdout, "Game restarted!\n");
}
Exemple #4
0
config default_map_generator::create_scenario()
{
	DBG_NG << "creating scenario...\n";

	config res = cfg_.child_or_empty("scenario");

	DBG_NG << "got scenario data...\n";

	std::map<map_location,std::string> labels;
	DBG_NG << "generating map...\n";

	try{
		res["map_data"] = generate_map(&labels);
	}
	catch (mapgen_exception& exc){
		res["map_data"] = "";
		res["error_message"] = exc.message;
	}
	DBG_NG << "done generating map..\n";

	for(std::map<map_location,std::string>::const_iterator i =
			labels.begin(); i != labels.end(); ++i) {

		if(i->first.x >= 0 && i->first.y >= 0 &&
				i->first.x < static_cast<long>(width_) &&
				i->first.y < static_cast<long>(height_)) {

			config& label = res.add_child("label");
			label["text"] = i->second;
			i->first.write(label);
		}
	}

	return res;
}
Exemple #5
0
int main() {
  srand(time(NULL));

  window = initscr();

  if (window == NULL) {
    fprintf(stderr, "error initialising curses.\n");
    return 1;
  }

  start_color();
  if (has_colors() && COLOR_PAIRS >= 13) {
    init_colors();
  }
  curs_set(0); // hide the cursor
  noecho(); // do not show characters when they've been typed

  generate_map();
  player = (Player) {
    .x_pos = 5,
    .y_pos = 5,
    .inventory = { (Item) { "", 0 } }
  };

  loop('\0');

  char key = '\0';
  while (key != 27) { // 27 = escape key
    key = getch();
    loop(key);
  }

  quit(window);
}
Exemple #6
0
int tuxrts_init(char *object_name, char *map_name, int players)
{
    FILE *fp;

    object_counter = 0;

    if(!init_players(players, 1))
    {
       printf("No players created!\n");
       DEBUGMSG(debug_game, "No players created!");
       return 0;
    }

    fp = LoadObj("objects");
    if(fp == NULL)
    {
        printf("File not found!\n");
        DEBUGMSG(debug_game, "File not found!");
        return 0;
    }
    printf("Object files in memory!\n");
    if(objects_xml(fp))
    {
        printf("Error parsing file!");
        DEBUGMSG(debug_game, "Error loading the objects description file.\n");
        return 0;
    }
    printf("Object file parsed.\n");
   
    fp = LoadMap(map_name);
    if(fp == NULL)
    {
        DEBUGMSG(debug_game, "File not found!");
        return 0;
    }
    printf("Map file in memory.\n");

    if(map_xml(fp))
    {
        printf("Error parsing file!");
        DEBUGMSG(debug_game, "Error loading the map file.\n");
        return 0;
    }
    printf("Map file parsed!\n");
    if(create_gmaps(players))
    {
        printf("Couldn't generate grpah mesh!\n");
        return 0;
    }
    
    generate_map();


    if(!panel_init())
    {
        printf("Error loading GUI.\n");
        return 0;
    }
    return 1;
}
Exemple #7
0
int main(){

	node* map = generate_map();
	printf("%f %f\n", map->pos.x, map->pos.y);
	printf("size = %d\n", sizeof(map));


	int start = rand() % 10;
	int end = rand() % 10;
	while(end == start)
		end = rand() % 10;
	node* p_node = &map[start];
	point* p_end = &map[end].pos;
	printf("%d :%f, %f\n", start, p_node->pos.x, p_node->pos.y);
	printf("%d :%f, %f\n", end, p_end->x, p_end->y);
	std::ofstream myfile;
	myfile.open("start_end.dat");
	myfile << p_node->pos.x << " " << p_node->pos.y << std::endl;
	myfile << p_end->x << " " << p_end->y << std::endl;
	myfile.close();



	printf("JUST DOIT\n");
	dfs(*p_node, *p_end);

	delete[] map;

	printf("final");
	//starting_edge = node();
	//ending_position_x, ending_position_y;
	return 0;
}
Exemple #8
0
int main(int argc, char* argv[]) {
    // Start the Dark Core Reactor!    
    dc_init(640, 480);

    world = dc_world_create();
    generate_map(&world);
    
    dc_object obj = dc_object_create();
    dc_object_set_x(&obj, 10);
    dc_object_set_y(&obj, 1);
    dc_object_set_on_key_press(&obj, obj_on_key_press);
    
    dc_world_add_object(&world, &obj);
    
    // Load the texture
    struct dc_texture tex;
    dc_texture_create(&tex, "resources/grass-tiles-2-small.png", "png");
    dc_world_add_texture(&world, &tex);
    
    // Map tiles to texture 
    dc_tile t1, t2, t3;
    dc_texture_map(&world, &t1, "Grass", 0, 0, 6, 2, 0);
    dc_world_add_tile(&world, &t1);
    dc_texture_map(&world, &t2, "Grass", 5, 0, 6, 2, 0);
    dc_world_add_tile(&world, &t2);
    dc_texture_map(&world, &t3, "Dirt", 4, 0, 6, 2, 1);
    dc_world_add_tile(&world, &t3);
    
    dc_run(&world);
            
    dc_texture_destory(&tex);

    return 0;
}
Exemple #9
0
int
main(int argc, char *argv[])
{
    FILE *out = stdout;
    struct options *options = options_alloc(argc, argv);
    
    if (options->error || options->help) {
        options_print_usage(options);
        return options->error? EXIT_FAILURE : EXIT_SUCCESS;
    }
    
    if (action_game == options->action) {
        play_game(options->rnd);
    } else if (action_tui == options->action) {
        run_tui();
    } else {
        fprintf(out, "Fiends and Fortune\n");
        switch (options->action) {
            case action_character:
                generate_character(options->rnd, out, options->character_method);
                break;
            case action_check:
                check(out, options->check_constant);
                break;
            case action_dungeon:
                if (options->dungeon_type_small) {
                    generate_sample_dungeon(options->rnd, out);
                } else {
                    generate_random_dungeon(options->rnd, out);
                }
                break;
            case action_each:
                generate_each_treasure(options->rnd, out);
                break;
            case action_magic:
                generate_magic_items(options->rnd, out, options->magic_count);
                break;
            case action_map:
                generate_map(options->rnd, out);
                break;
            case action_table:
                generate_treasure_type_table(out);
                break;
            case action_treasure:
                generate_treasure_type(options->rnd, out, options->treasure_type);
                break;
            default:
                fprintf(stderr, "%s: unrecognized option\n", options->command_name);
                break;
        }
        fprintf(out, "\n");
    }
    
    options_free(options);
    alloc_count_is_zero_or_die();
    return EXIT_SUCCESS;
}
Exemple #10
0
/**
 * Processes source code, writing the result to the output file.
 */
int generate(Pool *pool, FILE *out, Dynamic node)
{
  if(node.type == type_lookup)      return generate_lookup(pool, out, node.p);
  if(node.type == type_macro_call)  return generate_macro_call(pool, out, node.p);
  if(node.type == type_outline_item)return generate_outline_item(pool, out, node.p);
  if(node.type == type_map)         return generate_map(pool, out, node.p);
  if(node.type == type_for)         return generate_for(pool, out, node.p);
  if(node.type == type_code_text)   return generate_code_text(pool, out, node.p);
  assert(0);
  return 0;
}
Exemple #11
0
static void
check(FILE *out, uint32_t constant)
{
    struct rnd *fake_rnd = rnd_alloc_fake_fixed(constant);
    
    generate_treasure_type_table(out);
    generate_map(fake_rnd, out);
    generate_each_treasure(fake_rnd, out);
    generate_sample_dungeon(fake_rnd, out);
    generate_random_dungeon(fake_rnd, out);
    generate_character(fake_rnd, out, characteristic_generation_method_simple);
    generate_character(fake_rnd, out, characteristic_generation_method_1);
    generate_character(fake_rnd, out, characteristic_generation_method_2);
    generate_character(fake_rnd, out, characteristic_generation_method_3);
    generate_character(fake_rnd, out, characteristic_generation_method_4);
    generate_character(fake_rnd, out, characteristic_generation_method_general_NPC);
    generate_character(fake_rnd, out, characteristic_generation_method_special_NPC);
    
    rnd_free(fake_rnd);
}
Exemple #12
0
l_link::l_link()
{

	for(uint32_t i = 0; i < DIRECTIONS; ++i){
		if(i == 0){
			directions[i] = EAST;
		}
		else if(i == 1){
			directions[i] = SOUTH;
		}
		else if(i == 2){
			directions[i] = WEST;
		}
		else{
			directions[i] = NORTH;
		}
	}//for
	memset(&path, 0, sizeof(path));
	pair_count = 0;
	find_pairs = 0;
	generate_map();
}
/** Standalone testprogram for the mapgenerator. */
int main(int argc, char** argv)
{
	int x = 50, y = 50, iterations = 50,
		hill_size = 50, lakes=3,
	    nvillages = 25, nplayers = 2;
	if(argc >= 2) {
		x = std::stoi(argv[1]);
	}

	if(argc >= 3) {
		y = std::stoi(argv[2]);
	}

	if(argc >= 4) {
		iterations = std::stoi(argv[3]);
	}

	if(argc >= 5) {
		hill_size = std::stoi(argv[4]);
	}

	if(argc >= 6) {
		lakes = std::stoi(argv[5]);
	}

	if(argc >= 7) {
		nvillages = std::stoi(argv[6]);
	}

	if(argc >= 8) {
		nplayers = std::stoi(argv[7]);
	}

	srand(time(nullptr));
	std::cout << generate_map(x,y,iterations,hill_size,lakes,nvillages,nplayers) << "\n";
}
Exemple #14
0
int		main(int ac, char **av)
{
	int		i;

	if (ac > 1)
	{
		i = 1;
		while (i < ac)
		{
			if (ac != 2)
				put_file_path(av[i]);
			solve_map(av[i++]);
		}
	}
	else
	{
		generate_map();
		solve_map(MAP_PATH);
		if ((i = open(MAP_PATH, O_TRUNC)) <= 0)
			create_error(MAP_PATH);
		close(i);
	}
	return (0);
}
Exemple #15
0
std::string default_map_generator::create_map()
{
	return generate_map();
}
std::string default_map_generator::create_map(boost::optional<uint32_t> randomseed)
{
    return generate_map(nullptr, randomseed);
}
Exemple #17
0
int main (void) {
  	generate_map();
  	show_map();
   	return 0;
}
std::string default_map_generator::create_map(const std::vector<std::string>& args)
{
	return generate_map(args);
}