<commit_before>#pragma once

#include "../Composite.hpp"

namespace bt
{

/*
    The Sequence composite ticks each child node in order.
    If a child fails or runs, the sequence returns the same status.
    In the next tick, it will try to run each child in order again.
    If all children succeeds, only then does the sequence succeed.
*/
class Sequence : public Composite
{
public:
    void Initialize() override
    {
        index = 0;
    }

    Status Update() override
    {
        if (HasNoChildren()) {
            return Status::Success;
        }

        // Keep going until a child behavior says it's running.
        while (1) {
            auto &child = children.at(index);
            auto status = child->Tick();
            
            // If the child fails, or keeps running, do the same.
            if (status != Status::Success) {
                return status;
            }

            // Hit the end of the array, job done!
            if (++index == children.size()) {
                return Status::Success;
            }
        }
    }
};

}<commit_msg>added MakeSequence helper<commit_after>#pragma once

#include "../Composite.hpp"

namespace bt
{

/*
    The Sequence composite ticks each child node in order.
    If a child fails or runs, the sequence returns the same status.
    In the next tick, it will try to run each child in order again.
    If all children succeeds, only then does the sequence succeed.
*/
class Sequence : public Composite
{
public:
    void Initialize() override
    {
        index = 0;
    }

    Status Update() override
    {
        if (HasNoChildren()) {
            return Status::Success;
        }

        // Keep going until a child behavior says it's running.
        while (1) {
            auto &child = children.at(index);
            auto status = child->Tick();
            
            // If the child fails, or keeps running, do the same.
            if (status != Status::Success) {
                return status;
            }

            // Hit the end of the array, job done!
            if (++index == children.size()) {
                return Status::Success;
            }
        }
    }
    
    using Ptr = std::shared_ptr<Sequence>;
};

Sequence::Ptr MakeSequence()
{
    return std::make_shared<Sequence>();
}

}
{'fraction_non_alphanumeric': 0.09484625378951927, 'fraction_numerical': 0.0017323516673884798, 'mean_word_length': 1.7402135231316727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4905045', 'n_tokens_mistral': 615, 'n_tokens_neox': 591, 'n_words': 235}