<commit_before>﻿using System;

namespace _4_in_a_row_
{
    public enum player { Empty, Alice, Bob }
    public class Game
    {
        private static byte height;
        private static byte width;
        private readonly byte[][] field;

        //0 for noone, 1 for alice and 2 for bob
        public player next_player { get; private set; }
        private player winning { get; set; }
        /// <summary>
        /// A check if the specified person has won
        /// </summary>
        /// <param name="player">1 for alice, 2 for bob</param>
        public bool has_won(player player)
        {
            if (player == winning)
            {
                return true;
            }
            return false;

        }
        /// <summary>
        /// Initializes the field on 0;
        /// </summary>
        public Game(byte _width, byte _height)
        {
            height = _height;
            width = _width;
            field = new byte[_width][];
            for (int i = 0; i < field.Length; i++)
            {
                field[i] = new byte[height];
                for (int j = 0; j < field[i].Length; j++)
                {
                    //Console.WriteLine("X: " + i + ", Y: " + j);
                    field[i][j] = (byte)0;

                }
            }
            next_player = player.Alice;
            winning = 0;
        }

        public byte[][] get_field()
        {
            return field;
        }
        /// <summary>
        /// Adds a stone on top of the specified row
        /// </summary>
        /// <param name="row">The row that the stone must be added to. Minimum of 0 and Maximum of the height of the field</param>
        /// <param name="player">1 for Alice, 2 for Bob</param>
        /// <returns>If the stone could be placed in that row</returns>
        public bool add_stone(byte row, player player, ref string info)
        {
            if (next_player != player)
            {
                info = "It's not this players your turn";
                return false;
            }
            if (row >= field.Length)
            {
                info = "specified invalid (" + row + ") row";
                return false;
            }
            for (byte i = 0; i < height; i++)
            {

                if (field[row][i] == 0)
                {
                    field[row][i] = (byte)player;
                    Console.WriteLine("Dropped a stone for {0} at {1}, {2}", ((int)player == 1 ? "alice" : "bob"), row, i);
                    check_for_win(row, i, player);
                    if (player == player.Alice)
                    {
                        next_player = player.Bob;
                    }
                    else
                    {
                        next_player = player.Alice;
                    }
                    return true;
                }
            }
            info = "row " + row + " is already full";
            return false;
        }
        #region check_for_win
        /// <summary>
        /// Checks if someone has won
        /// </summary>
        /// <p>
        /// Checks in each direction from the given stone if it can make a whole row. If so, the variable winning will be changed
        /// </p>
        /// <param name="x">The x of the given stone</param>
        /// <param name="y">The y of the given stone</param>
        /// <param name="player">1 for alice, 2 for bob</param>
        private void check_for_win(byte x, byte y, player player)
        {<commit_msg>Replaced row with column.<commit_after>﻿using System;

namespace _4_in_a_row_
{
    public enum player { Empty, Alice, Bob }
    public class Game
    {
        private static byte height;
        private static byte width;
        private readonly byte[][] field;

        //0 for noone, 1 for alice and 2 for bob
        public player next_player { get; private set; }
        private player winning { get; set; }
        /// <summary>
        /// A check if the specified person has won
        /// </summary>
        /// <param name="player">1 for alice, 2 for bob</param>
        public bool has_won(player player)
        {
            if (player == winning)
            {
                return true;
            }
            return false;

        }
        /// <summary>
        /// Initializes the field on 0;
        /// </summary>
        public Game(byte _width, byte _height)
        {
            height = _height;
            width = _width;
            field = new byte[_width][];
            for (int i = 0; i < field.Length; i++)
            {
                field[i] = new byte[height];
                for (int j = 0; j < field[i].Length; j++)
                {
                    //Console.WriteLine("X: " + i + ", Y: " + j);
                    field[i][j] = (byte)0;

                }
            }
            next_player = player.Alice;
            winning = 0;
        }

        public byte[][] get_field()
        {
            return field;
        }
        /// <summary>
        /// Adds a stone on top of the specified column
        /// </summary>
        /// <param name="column">The column that the stone must be added to. Minimum of 0 and Maximum of the width of the field</param>
        /// <param name="player">1 for Alice, 2 for Bob</param>
        /// <returns>If the stone could be placed in that column</returns>
        public bool add_stone(byte column, player player, ref string info)
        {
            if (next_player != player)
            {
                info = "It's not this players your turn";
                return false;
            }
            if (column >= field.Length)
            {
                info = "specified invalid (" + column + ") column";
                return false;
            }
            for (byte i = 0; i < height; i++)
            {

                if (field[column][i] == 0)
                {
                    field[column][i] = (byte)player;
                    Console.WriteLine("Dropped a stone for {0} at {1}, {2}", ((int)player == 1 ? "alice" : "bob"), column, i);
                    check_for_win(column, i, player);
                    if (player == player.Alice)
                    {
                        next_player = player.Bob;
                    }
                    else
                    {
                        next_player = player.Alice;
                    }
                    return true;
                }
            }
            info = "column " + column + " is already full";
            return false;
        }
        #region check_for_win
        /// <summary>
        /// Checks if someone has won
        /// </summary>
        /// <p>
        /// Checks in each direction from the given stone if it can make a whole row. If so, the variable winning will be changed
        /// </p>
        /// <param name="x">The x of the given stone</param>
        /// <param name="y">The y of the given stone</param>
        /// <param name="player">1 for alice, 2 for bob</param>
        private void check_for_win(byte x, byte y, player player)
        {
{'fraction_non_alphanumeric': 0.1134223471539002, 'fraction_numerical': 0.0061841180604357, 'mean_word_length': 1.1741521539871678, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 53, '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': '614431', 'n_tokens_mistral': 1926, 'n_tokens_neox': 1822, 'n_words': 631}