Exemplo n.º 1
0
int			main(void)
{
	t_dmain		dmain1;

	ft_init12(&dmain1);
	ft_read_map(&dmain1, &(dmain1.data1), &(dmain1.map1));
	if (ft_checkmindata(dmain1.data1, dmain1.node2) == 0)
	{
		write(1, "ERROR", 5);
		return (0);
	}
	dmain1.nodedummie = ft_generate2(dmain1.node2, dmain1.data1.strbegi,
			dmain1.data1.strend);
	dmain1.nodedata = ft_screen(&(dmain1.nodedata), dmain1);
	if (dmain1.nodedata == NULL)
	{
		write(1, "ERROR", 5);
		return (0);
	}
	ft_printsol(dmain1.map1.nodemap);
	ft_putstr("\n");
	dmain1.nodebest = ft_screenbest(&(dmain1.nodebest), dmain1.nodedata,
			(dmain1.data1).strend);
	if (dmain1.nodebest)
		ft_simuldirect(dmain1.nodebest,
				(dmain1.data1).strend, (dmain1.data1).nbant);
	return (1);
}
Exemplo n.º 2
0
void			ft_open_map(t_a *a, char *name)
{
	if ((a->fd1 = open(name, O_RDONLY)) == -1)
		ft_error("File Not Present / No Rights");
	while (get_next_line(a->fd1, &a->line) > 0)
	{
		if (a->max_y == 0)
			a->max_x = count_carac(a->line);
		if (a->max_y != 0)
			if (a->max_x != count_carac(a->line))
				ft_error("The Map is Invalid");
		a->max_y++;
		free(a->line);
	}
	free(a->line);
	if (a->max_x == 0 || a->max_y == 0)
		ft_error("The Map is Invalid");
	ft_creat_map(a);
	ft_read_map(a, name);
}