<commit_before>package bt;

import ec.EvolutionState;
import ec.gp.GPIndividual;
import ec.gp.GPNode;
import ec.util.Parameter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;

/**
 * Created by Hallvard on 14.09.2015.
 */
public abstract class Composite<E> extends Task<E> {

    public boolean deterministic = true;

    protected int childIndex;

    public Composite(ArrayList<Task<E>> tasks) {
        this.childTasks = tasks;
    }

    @Override
    public void childRunning(Task<E> focal, Task<E> nonFocal) {
        super.childRunning(focal, nonFocal);
        running();
    }

    @Override
    public void run() {
        if (runningTask != null)
            runningTask.run();
        else {
            if (childIndex < childTasks.size()) {
                if (!deterministic) {
                    final int lastChild = childTasks.size() - 1;
                    if (childIndex < lastChild)
                        Collections.shuffle(childTasks.subList(childIndex, lastChild));
                }
                runningTask = childTasks.get(childIndex);
                runningTask.setParent(this);
                runningTask.start();
                run();
            } else
                end(); //Should not happen...
        }
    }

    @Override
    public void start() {
        this.childIndex = 0;
        runningTask = null;<commit_msg>Randomized children last child deterministic bug fix<commit_after>package bt;

import ec.EvolutionState;
import ec.gp.GPIndividual;
import ec.gp.GPNode;
import ec.util.Parameter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.stream.Collectors;

/**
 * Created by Hallvard on 14.09.2015.
 */
public abstract class Composite<E> extends Task<E> {

    public boolean deterministic = true;

    protected int childIndex;

    public Composite(ArrayList<Task<E>> tasks) {
        this.childTasks = tasks;
    }

    @Override
    public void childRunning(Task<E> focal, Task<E> nonFocal) {
        super.childRunning(focal, nonFocal);
        running();
    }

    @Override
    public void run() {
        if (runningTask != null)
            runningTask.run();
        else {
            if (childIndex < childTasks.size()) {
                if (!deterministic) {
                    Collections.shuffle(childTasks.subList(childIndex, childTasks.size()));
                }
                runningTask = childTasks.get(childIndex);
                runningTask.setParent(this);
                runningTask.start();
                run();
            } else
                end(); //Should not happen...
        }
    }

    @Override
    public void start() {
        this.childIndex = 0;
        runningTask = null;
{'fraction_non_alphanumeric': 0.10627674750356633, 'fraction_numerical': 0.006776034236804565, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1324597', 'n_tokens_mistral': 809, 'n_tokens_neox': 753, 'n_words': 183}