<commit_before>﻿using System;

namespace temporalcohesion.gol.core
{
    public interface IGridPopulationStrategy
    {
        Cell[,] Populate(int x, int y);
    }

    public class DefaultGridPopulationStrategy : IGridPopulationStrategy
    {
        private readonly int _seed;

        public DefaultGridPopulationStrategy(int seed)
        {
            _seed = seed;
        }

        public Cell[,] Populate(int x, int y)
        {
            var grid = new Cell[x, y];

            for (var i = 0; i < x; i++)
            {
                for (var j = 0; j < y; j++)
                {
                    var cell = new Cell(j, i) { Alive = AliveOrDead(j, i) };
                    grid[j, i] = cell;
                }
            }

            return grid;
        }

        private bool AliveOrDead(int x, int y)
        {
            var random = new Random(_seed);

            return (((x ^ y) + random.Next()) % 5) == 0;
        }

    }
}<commit_msg>Add strategy for glider and a row<commit_after>﻿using System;

namespace temporalcohesion.gol.core
{
    public interface IGridPopulationStrategy
    {
        Cell[,] Populate(int x, int y);
    }

    public class DefaultGridPopulationStrategy : IGridPopulationStrategy
    {
        private readonly int _seed;

        public DefaultGridPopulationStrategy(int seed)
        {
            _seed = seed;
        }

        public Cell[,] Populate(int x, int y)
        {
            var grid = new Cell[x, y];

            for (var i = 0; i < x; i++)
            {
                for (var j = 0; j < y; j++)
                {
                    var cell = new Cell(i, j) { Alive = AliveOrDead(i, j) };
                    grid[i, j] = cell;
                }
            }

            return grid;
        }

        private bool AliveOrDead(int x, int y)
        {
            var random = new Random(_seed);

            return (((x ^ y) + random.Next()) % 5) == 0;
        }

    }

    public class GliderPopulationStrategy : IGridPopulationStrategy
    {
        public Cell[,] Populate(int x, int y)
        {
            var grid = new Cell[x, y];

            for (var i = 0; i < x; i++)
            {
                for (var j = 0; j < y; j++)
                {
                    var cell = new Cell(i, j) { Alive = false };
                    grid[i, j] = cell;
                }
            }

            CreateGlider(grid);

            return grid;
        }

        private void CreateGlider(Cell[,] grid)
        {
            grid[2, 1].Alive = true;
            grid[1, 3].Alive = true;
            grid[2, 3].Alive = true;
            grid[3, 3].Alive = true;
            grid[3, 2].Alive = true;
        }
    }

    public class TenCellRowPopulationStrategy : IGridPopulationStrategy
    {
        public Cell[,] Populate(int x, int y)
        {
            var grid = new Cell[x, y];

            for (var i = 0; i < x; i++)
            {
                for (var j = 0; j < y; j++)
                {
                    var cell = new Cell(i, j) { Alive = false };
                    grid[i, j] = cell;
                }
            }

            CreateRow(grid);

            return grid;
        }

        private void CreateRow(Cell[,] grid)
        {
            grid[10, 10].Alive = true;
            grid[10, 11].Alive = true;
            grid[10, 12].Alive = true;
            grid[10, 13].Alive = true;
            grid[10, 14].Alive = true;
            grid[10, 15].Alive = true;
            grid[10, 16].Alive = true;
            grid[10, 17].Alive = true;
            grid[10, 18].Alive = true;
            grid[10, 19].Alive = true;
        }
    }
}
{'fraction_non_alphanumeric': 0.11283728536385937, 'fraction_numerical': 0.016898337421640774, 'mean_word_length': 1.1793349168646081, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '3137299', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1056, 'n_words': 301}