Exemple #1
0
void					resolve(t_colony *colony)
{
	colony->number_of_ants_in_start = colony->number_of_ants;
	while (colony->number_of_ants_in_end != colony->number_of_ants)
	{
		move_ants(colony);
		if (!colony->hide_ants_moves)
			ft_printf("\n");
		++colony->turns;
	}
	if (colony->display_nb_moves)
		ft_printf("moves required : [%[[FG_RED,SP_RST]d]\n", colony->moves);
	if (colony->display_nb_turns)
		ft_printf("Turns required : [%[[FG_GRE,SP_RST]d]\n", colony->turns);
}
Exemple #2
0
void			ft_move_ants(t_hall **hall, t_ants **ants)
{
	t_hall		*start;
	t_hall		*end;
	int			nbr_ants;

	nbr_ants = (*ants)->nbr_ants;
	start = *hall;
	end = *hall;
	while (start->stat != 1)
		start = start->next;
	start->nbr_ants = nbr_ants;
	while (end->stat != 2)
		end = end->next;
	ft_putchar('\n');
	ft_del_bad_path(hall);
	move_ants(start, end, ants);
}