<commit_before>class Board
  attr_reader :spaces

  def initialize
    @spaces = [nil] * 9
  end

  def place_mark(space, mark)
    return false unless valid_space? space
    @spaces[space] = mark
  end

  def num_available_spaces
    spaces.count { |space| space.nil? }
  end

  def valid_space?(space)
    @spaces[space].nil? && (0..9).include?(space)
  end

  def build_grid
    print "\n\n"
    (0..8).each do |i|
      print_space i
      # Add some formatting to make the grid
      print ' | ' unless [2, 5, 8].include? i
      print "\n----------\n" if [2, 5].include? i
    end
    print "\n\n\n"
  end

  def print_space(i)
    if spaces[i] # space is occupied with X or O
      print spaces[i]
    else # space i is nil, just print the space #
      print i
    end
  end

  def random_available_space
    found_space = false

    until found_space
      space = rand(9) # Get a random number between 0 and 8
      found_space = valid_space? space # Make sure it's valid
    end
    space
  end

  def spaces_occupied_by(symbol)
    a = []
    (0..8).each do |i|
      a << i if spaces[i] == symbol
    end
    return a
  end
end<commit_msg>Added terminal colors<commit_after>require 'term/ansicolor'
include Term::ANSIColor

class Board
  attr_reader :spaces

  def initialize
    @spaces = [nil] * 9
  end

  def place_mark(space, mark)
    return false unless valid_space? space
    @spaces[space] = mark
  end

  def num_available_spaces
    spaces.count { |space| space.nil? }
  end

  def valid_space?(space)
    @spaces[space].nil? && (0..9).include?(space)
  end

  def build_grid
    print "\n\n"
    (0..8).each do |i|
      print_space i
      # Add some formatting to make the grid
      print ' | ' unless [2, 5, 8].include? i
      print "\n----------\n" if [2, 5].include? i
    end
    print "\n\n\n"
  end

  def print_space(i)
    if spaces[i] # space is occupied with X or O
      if spaces[i] == :O
        print magenta, bold, "#{spaces[i]}", reset
      else
        print cyan, bold, "#{spaces[i]}", reset
      end
    else # space i is nil, just print the space #
      print i
    end
  end

  def random_available_space
    found_space = false

    until found_space
      space = rand(9) # Get a random number between 0 and 8
      found_space = valid_space? space # Make sure it's valid
    end
    space
  end

  def spaces_occupied_by(symbol)
    a = []
    (0..8).each do |i|
      a << i if spaces[i] == symbol
    end
    return a
  end
end
{'fraction_non_alphanumeric': 0.11106639839034205, 'fraction_numerical': 0.012072434607645875, 'mean_word_length': 2.216041397153946, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6926513', 'n_tokens_mistral': 881, 'n_tokens_neox': 834, 'n_words': 282}