<commit_before>require './move.rb'
require './square.rb'

class State

  attr_accessor :board

  def initializer(mn, mc)
    @maxTurns = 80
    @move_next = mn
    @move_current = mc
    @board = []
  end

  def print_board
    @board.each do |x|
      puts x.join("")
    end
  end

  def read_board
  end

  def init_board
    @board = [
      ['k','q','b','n','r'],
      ['p','p','p','p','p'],
      ['.','.','.','.','.'],
      ['.','.','.','.','.'],
      ['P','P','P','P','P'],
      ['R','N','B','Q','K'],
    ]
  end

  def humanMove(move)

  end

  def move(m)
    if m.nil? and m.side?
      State.new
    else
      throw "move error"
    end
  end

  def moveScan(x0, y0, dx, dy, capture=true, stop_short=false)
    x = x0
    y = y0
    c = getColor(x0,y0)
    moves = []

    loop do
      x += dx
      y += dy
      break if not inBounds?(x,y)

      if isOccupied?(@board[y][x])
        break if getColor(x,y) == c
        break if not capture
        stop_short = true
      end

      validMove = Move.new(Square.new(x0,y0), Square.new(x,y))
      moves << validMove
      break if stop_short == true
    end

    return moves
  end

  def getColor(x, y)
    if @board[y, x].to_s.upcase == @board[y, x]
      "W"
    else
      "B"
    end
  end

  def isOccupied?(value)
    value != '.'
  end

  def inBounds?(x,y)
    x < 5 && x > 0 or y < 6 and y > -1
  end

  def moveGen
    # scan board
    # generate moves for each piece
    # return list of possible moves
  end

  def moveList(x,y)

    # To list the moves of a piece at x, y: 
    p = @board[y][x].to_s.upcase
    moves = []
<commit_msg>Fix logic error in bounds method<commit_after>require './move.rb'
require './square.rb'

class State

  attr_accessor :board

  def initializer(mn, mc)
    @maxTurns = 80
    @move_next = mn
    @move_current = mc
    @board = []
  end

  def print_board
    @board.each do |x|
      puts x.join("")
    end
  end

  def read_board
  end

  def init_board
    @board = [
      ['k','q','b','n','r'],
      ['p','p','p','p','p'],
      ['.','.','.','.','.'],
      ['.','.','.','.','.'],
      ['P','P','P','P','P'],
      ['R','N','B','Q','K'],
    ]
  end

  def humanMove(move)

  end

  def move(m)
    if m.nil? and m.side?
      State.new
    else
      throw "move error"
    end
  end

  def moveScan(x0, y0, dx, dy, capture=true, stop_short=false)
    x = x0
    y = y0
    c = getColor(x0,y0)
    moves = []

    loop do
      x += dx
      y += dy
      break if not inBounds?(x,y)

      if isOccupied?(@board[y][x])
        break if getColor(x,y) == c
        break if not capture
        stop_short = true
      end

      validMove = Move.new(Square.new(x0,y0), Square.new(x,y))
      @board[y][x] = '%'
      moves << validMove
      break if stop_short == true
    end

    return moves
  end

  def getColor(x, y)
    if @board[y, x].to_s.upcase == @board[y, x]
      "W"
    else
      "B"
    end
  end

  def isOccupied?(value)
    value != '.'
  end

  def inBounds?(x,y)
    x < 5 and x > -1 and y < 6 and y > -1
  end

  def moveGen
    # scan board
    # generate moves for each piece
    # return list of possible moves
  end

  def moveList(x,y)

    # To list the moves of a piece at x, y: 
    p = @board[y][x].to_s.upcase
    moves = []

{'fraction_non_alphanumeric': 0.17168949771689498, 'fraction_numerical': 0.00852359208523592, 'mean_word_length': 1.9182948490230907, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1575941', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1276, 'n_words': 337}