<commit_before>#include "core/Observer.hpp"
#include "core/SquareLattice.hpp"
#include "sdl/RenderableWindow.hpp"

namespace miniascape
{

template<typename T_traits>
class GraphicalObserver : public Observer<T_traits>
{
  public:
    using base_type   = Observer<T_traits>;
    using state_type  = typename base_type::state_type;
    using cell_type   = typename base_type::cell_type;
    using time_type   = typename base_type::time_type;
    using world_type  = typename base_type::world_type;

  public:
    GraphicalObserver(const std::size_t x, const std::size_t y)
        : window_(x, y)
    {}
    ~GraphicalObserver() = default;

    void observe(const time_type& t, const world_type& world) override;

  private:
    sdl::RenderableWindow window_;
};

template<typename T_traits>
void GraphicalObserver<T_traits>::observe(
        const time_type& t, const world_type& world)
{
    const auto size = window_.size();
    const sdl::Color green{0, 255, 0, 0};
    const sdl::Color black{0,   0, 0, 0};
    window_.clear(black);
    for(int x = 0; x < size.first; ++x)
    for(int y = 0; y < size.second; ++y)
    {
        sdl::Point pos{x, y};
        if((dynamic_cast<SquareLattice<T_traits> const&>(world)(x, y))->state)
            window_.putpixel(pos, green);
    }
    window_.update();
    return;
}





}<commit_msg>change class name and fix sdl system call<commit_after>#include "core/Observer.hpp"
#include "core/SquareLattice.hpp"
#include "sdl/RenderableWindow.hpp"
#include "sdl/System.hpp"

namespace miniascape
{

template<typename T_traits>
class ConwaysLifeGameVisualizer : public Observer<T_traits>
{
  public:
    using base_type   = Observer<T_traits>;
    using state_type  = typename base_type::state_type;
    using cell_type   = typename base_type::cell_type;
    using time_type   = typename base_type::time_type;
    using world_type  = typename base_type::world_type;

  public:
    ConwaysLifeGameVisualizer(const std::size_t x, const std::size_t y)
        : system_(SDL_INIT_VIDEO), window_(x, y)
    {
        const sdl::Color black{0, 0, 0, 0};
        window_.clear(black);
        window_.update();
    }
    ~ConwaysLifeGameVisualizer()
    {
        window_.~RenderableWindow();
        system_.~System();
    }

    void observe(const time_type& t, const world_type& world) override;

  private:
    sdl::System           system_;
    sdl::RenderableWindow window_;
};

template<typename T_traits>
void ConwaysLifeGameVisualizer<T_traits>::observe(
        const time_type& t, const world_type& world)
{
    const auto size = window_.size();
    const sdl::Color green{0, 255, 0, 0};
    const sdl::Color black{0,   0, 0, 0};
    window_.clear(black);
    for(int x = 0; x < size.first; ++x)
    for(int y = 0; y < size.second; ++y)
    {
        sdl::Point pos{x, y};
        if((dynamic_cast<SquareLattice<T_traits> const&>(world)(x, y))->state)
            window_.putpixel(pos, green);
    }
    window_.update();
    window_.wait(std::chrono::microseconds(10));
    return;
}

}
{'fraction_non_alphanumeric': 0.12636093698449358, 'fraction_numerical': 0.009897723523589575, 'mean_word_length': 3.471976401179941, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '6580789', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1005, 'n_words': 232}