Example #1
0
void			map_manager(t_map **map, t_path **antpit)
{
	int			i;

	i = 0;
	while ((*map)->cleanfile[i] != NULL)
	{
		if ((*map)->nb_ants == 0)
			check_ants(map, i, 0);
		i++;
	}
	i = (*map)->antindex + 1;
	while ((*map)->error != 1 && (*map)->cleanfile[i] != NULL)
	{
		if ((isroom(map, i, antpit)) == 0 && (istube(map, i, antpit)) == 0)
		{
			if (iscommand(map, i, antpit) <= 0)
				(*map)->error = 1;
		}
		i++;
	}
	error_manager(map, antpit);
	max_paths(antpit);
	matrix_duplicator(antpit);
}
Example #2
0
void	apply_path(t_hex *lst, t_path *ants)
{
	if ((ants = (t_path*)malloc(sizeof(t_path) * (lst->ants))) == NULL)
		error("ERROR : Malloc NULL.");
	lst = initialyze_ants(lst, &ants, 0, 0);
	ft_putchar('\n');
	while (check_ants(&ants, lst) == 0)
	{
		while (ants[IND].checkend == 1 || check_room(ants, lst,
					lst->path[ants[IND].index][ants[IND].index2]) == 1)
		{
			IND++;
			lst = count(lst);
		}
		if (lst->path[ants[IND].index][ants[IND].index2])
		{
			if (lst->i2 != 0)
				ft_putchar(' ');
			ft_printf("L%d-%s", IND + 1,
					lst->path[ants[IND].index][ants[IND].index2]);
			lst->i2++;
		}
		ants[IND].room = lst->path[ants[IND].index][ants[IND].index2];
		ants[IND].index2++;
		IND++;
		lst = count(lst);
	}
}
Example #3
0
int		check_map(char *str, t_infos *infos, t_list **rooms)
{
	if (check_ants(str, infos) == 1)
		return (1);
	else if (check_start(str, infos) == 1 && infos->ok != 2)
	 	return (1);
	else if (check_end(str, infos) == 1 && infos->ok != 2)
	 	return (1);
	else if(check_pos(str, rooms, infos) == 1)
		return (1);
	else if(check_tubes(str, infos, rooms) == 1)
	 	return (1);
	return (0);
}