Пример #1
0
Файл: main.c Проект: kelu27/42
int		main(int argc, char **argv)
{
	char	*line;

	if (argc != 3)
	{
		ft_badarg();
		return (0);
	}
	else
	{
		ft_create_map(argv[1], argv[2]);
		ft_print_map();
		while (42)
		{
			ft_putstr("Column number: ");
			if (get_next_line(0, &line) == 0)
				return (0);
			if (ft_putoken(argv[1], argv[2], line) == 1)
				return (0);
			ft_putendl("IA play");
			if (get_next_line(0, &line) == 0)
				return (0);
			if (ft_putoken2(argv[1], argv[2], line) == 1)
				return (0);
		}
	}
	return (0);
}
Пример #2
0
void	ft_main2(int fd)
{
	char		*file;
	t_map		map;
	t_tetri		*tetri;

	if (!(file = ft_getfile(fd, &map)) ||
			!(ft_check_file(file)))
		ft_putstr("error\n");
	else
	{
		tetri = ft_create_tetri(map);
		ft_fill(tetri, file, map);
		ft_init_map(&map);
		map.ret = 1;
		ft_solve(tetri, &map);
		while (map.ret == 0)
		{
			map.size++;
			ft_solve(tetri, &map);
		}
		ft_print_map(tetri, map);
		ft_free(&tetri);
	}
}
Пример #3
0
int		main(int argc, char **argv)
{
	int		***tab;
	t_conf	conf;
	t_data	d;

	if (argc != 2)
	{
		ft_putstr("usage: ./fdf [data_file]");
		return (0);
	}
	tab = ft_get_data(argv, &conf);
	d.map = tab;
	d.wall = conf.wall;
	d.col = conf.x;
	d.li = conf.y;
	d.empty = conf.empty;
	d.p = (t_point *)malloc(sizeof(t_point));
	d.p->x = 1040;
	d.p->y = 1104;
	d.alpha = 0;
	ft_init_attr(&d);
	ft_print_map(d.map);
	ft_mlx(&d);
	return (0);
}
Пример #4
0
void	ft_calcul_tetri(t_tetri **list)
{
	char	**map;
	double	tmp;
	int		size;
	t_pos	p;
	t_nb	nb;

	nb.nb_list = ft_count_tetri(*list);
	tmp = ft_sqrt(nb.nb_list * 4);
	size = tmp;
	if (tmp - size > 0.0)
		size++;
	map = ft_generate_map(size);
	nb.max = ft_strlen(map[0]);
	p.y = 0;
	p.x = 0;
	while (ft_place_tetri(*list, map, p, nb) == 0)
	{
		free(map);
		size++;
		map = ft_generate_map(size);
		nb.max = ft_strlen(map[0]);
	}
	ft_print_map(map);
	ft_clean_memory(list, map);
}
Пример #5
0
int		fill_in(int **map, int position, int nb)
{
	int	i;
	int	j;

	if (position == 81)
	{
		ft_print_map(map);
		return (1);
	}
	i = position / 9;
	j = position % 9;
	if (map[i][j] != 0)
		return (fill_in(map, position + 1, nb));
	nb = 1;
	while (nb <= 9)
	{
		if (c_row(nb, map, i) && c_col(nb, map, j) && c_sqr(nb, map, i, j))
		{
			map[i][j] = nb;
			if (fill_in(map, position + 1, nb))
				return (1);
		}
		nb++;
	}
	map[i][j] = 0;
	return (0);
}
Пример #6
0
void	ft_run_bsq(char **map, t_map *map_info)
{
	map_info->width--;
	map_info->height--;
	ft_bsq(map, map_info);
	ft_print_map(map, PRINT_SPACES);
	free(map);
}
Пример #7
0
void	ft_resolve(t_piece *pieces, t_map *map, int nb_pieces)
{
	int	ret;
	int	pos;

	pos = 0;
	map->nb_pieces = nb_pieces;
	while (!(ret = insert(pieces, map, &pos)))
		map = ft_resize_map(map);
	ft_print_map(map);
}
Пример #8
0
void			ft_solve(t_tetros *tetro, int nb_tetros)
{
	char	**map;
	int		size;

	size = nb_tetros / 2;
	map = ft_gen_map(size);
	ft_adj_tetro(tetro);
	while (ft_try(tetro, map, size) == 0)
	{
		tetro->x = 0;
		tetro->y = 0;
		size++;
		ft_free_tetros(map, size);
		map = ft_gen_map(size);
	}
	ft_print_map(map);
}
Пример #9
0
int			main(int ac, char **av)
{
	char	*buffer;
	int		cnt_tetri;
	int		***tetri;
	int		**map;

	ft_check_ac(ac);
	buffer = ft_get_file(av[1]);
	ft_check_file(buffer);
	cnt_tetri = ft_count_tetri(buffer);
	tetri = ft_split_tetri(buffer);
	map = ft_resol(tetri, cnt_tetri);
	ft_print_map(map);
	ft_free_map(map);
	map = NULL;
	ft_free_tetri(tetri, cnt_tetri);
	tetri = NULL;
	return (0);
}