spring cleanup =)
normalized all algo files ready for integration
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/18 18:05:06 by tmaze #+# #+# */
|
||||
/* Updated: 2019/04/19 12:52:45 by tmaze ### ########.fr */
|
||||
/* Updated: 2019/04/21 16:53:11 by tmaze ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -37,6 +37,36 @@ static int get_nb_nodes(t_ind *lst)
|
||||
return (i);
|
||||
}
|
||||
|
||||
static int get_min_score(t_ind **ret, int *scores)
|
||||
{
|
||||
int i;
|
||||
int min;
|
||||
|
||||
i = -1;
|
||||
min = FT_INT_MAX;
|
||||
while (ret[++i])
|
||||
if (min > scores[i])
|
||||
min = scores[i];
|
||||
return (min);
|
||||
}
|
||||
|
||||
static int get_final_score(t_ind **ret, int *scores)
|
||||
{
|
||||
int i;
|
||||
int min;
|
||||
|
||||
i = -1;
|
||||
min = 0;
|
||||
while (ret[++i])
|
||||
{
|
||||
scores[i] = (ret[i]->weight > 0) * (get_nb_nodes(ret[i])
|
||||
+ ret[i]->weight - 1);
|
||||
if (min < scores[i])
|
||||
min = scores[i];
|
||||
}
|
||||
return (min);
|
||||
}
|
||||
|
||||
int get_score(t_lmdata *data, t_ind **ret, int nb_paths)
|
||||
{
|
||||
int nbants;
|
||||
@@ -44,46 +74,20 @@ int get_score(t_lmdata *data, t_ind **ret, int nb_paths)
|
||||
int min;
|
||||
int scores[nb_paths];
|
||||
|
||||
if (nb_paths == 1)
|
||||
nbants = data->nbants;
|
||||
init_scores(ret, scores);
|
||||
min = get_min_score(ret, scores);
|
||||
while (nbants > 0 && (i = -1))
|
||||
{
|
||||
ret[0]->weight = data->nbants;
|
||||
min = (ret[0]->weight > 0) * (get_nb_nodes(ret[0]) + ret[0]->weight - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
min = FT_INT_MAX;
|
||||
i = -1;
|
||||
nbants = data->nbants;
|
||||
init_scores(ret, scores);
|
||||
while (ret[++i])
|
||||
if (min > scores[i])
|
||||
min = scores[i];
|
||||
while (nbants > 0 && !(i = 0))
|
||||
{
|
||||
while (i < nb_paths && nbants > 0)
|
||||
while (++i < nb_paths && nbants > 0)
|
||||
if (scores[i] == min)
|
||||
{
|
||||
if (scores[i] == min)
|
||||
{
|
||||
nbants--;
|
||||
ret[i]->weight++;
|
||||
scores[i] = (ret[i]->weight > 0) * (get_nb_nodes(ret[i]) + ret[i]->weight - 1);
|
||||
}
|
||||
i++;
|
||||
nbants--;
|
||||
ret[i]->weight++;
|
||||
scores[i] = (ret[i]->weight > 0) * (get_nb_nodes(ret[i])
|
||||
+ ret[i]->weight - 1);
|
||||
}
|
||||
i = -1;
|
||||
min = FT_INT_MAX;
|
||||
while (ret[++i])
|
||||
if (min > scores[i])
|
||||
min = scores[i];
|
||||
}
|
||||
i = -1;
|
||||
min = 0;
|
||||
while (ret[++i])
|
||||
{
|
||||
scores[i] = (ret[i]->weight > 0) * (get_nb_nodes(ret[i]) + ret[i]->weight - 1);
|
||||
if (min < scores[i])
|
||||
min = scores[i];
|
||||
}
|
||||
min = get_min_score(ret, scores);
|
||||
}
|
||||
return (min);
|
||||
return (get_final_score(ret, scores));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user