def move_lateral(index, limit = 8)
      row = get_row_from_index(index)
      col = get_col_from_index(index)

      left  = [col - 1, limit].min
      right = [8 - col, limit].min
      up    = [row - 1, limit].min
      down  = [8 - row, limit].min

      valid = []

      # Move down N places until board limit, piece in the way, or specified limit
      down.times do |i|
        next_pos = index + (i + 1) * 8
        # Valid move if position is unoccupied
        if unoccupied?(next_pos)
          valid << next_pos
        else
          # Valid move is piece is an enemy, but then no subsequent tiles are attackable
          # if the piece is not an enemy, it's not added as a valid move, and no subsequent tiles are attackable
          # This function doesn't filter out the king from a valid enemy, but the Board class will drop King indexes
          valid << next_pos if piece_color(next_pos) == Move.enemy_color

          break
        end
      end

      # Move up N places until board limit, piece in the way, or specified limit
      up.times do |i|
        next_pos = index - (i + 1) * 8
        if unoccupied?(next_pos)
          valid << next_pos
        else
          valid << next_pos if piece_color(next_pos) == Move.enemy_color
          break
        end
      end

      # Move right N places until board limit, piece in the way, or specified limit
      right.times do |i|
        next_pos = index + (i + 1)
        if unoccupied?(next_pos)
          valid << next_pos
        else
          valid << next_pos if piece_color(next_pos) == Move.enemy_color
          break
        end
      end

      # Move left N places until board limit, piece in the way, or specified limit
      left.times do |i|
        next_pos = index - (i + 1)
        if unoccupied?(next_pos)
          valid << next_pos
        else
          valid << next_pos if piece_color(next_pos) == Move.enemy_color
          break
        end
      end

      valid
    end
def move_lateral(index, limit = 8)
      row = get_row_from_index(index)
      col = get_col_from_index(index)

      left  = [col - 1, limit].min
      right = [8 - col, limit].min
      up    = [row - 1, limit].min
      down  = [8 - row, limit].min

      valid = []

      # Move down N places until board limit, piece in the way, or specified limit
      down.times do |i|
        next_pos = index + (i + 1) * 8
        # Valid move if position is unoccupied
        if unoccupied?(next_pos)
          valid << next_pos
        else
          # Valid move is piece is an enemy, but then no subsequent tiles are attackable
          # if the piece is not an enemy, it's not added as a valid move, and no subsequent tiles are attackable
          # This function doesn't filter out the king from a valid enemy, but the Board class will drop King indexes
          valid << next_pos if piece_color(next_pos) == Move.enemy_color

          break
        end
      end

      # Move up N places until board limit, piece in the way, or specified limit
      up.times do |i|
        next_pos = index - (i + 1) * 8
        if unoccupied?(next_pos)
          valid << next_pos
        else
          valid << next_pos if piece_color(next_pos) == Move.enemy_color
          break
        end
      end

      # Move right N places until board limit, piece in the way, or specified limit
      right.times do |i|
        next_pos = index + (i + 1)
        if unoccupied?(next_pos)
          valid << next_pos
        else
          valid << next_pos if piece_color(next_pos) == Move.enemy_color
          break
        end
      end

      # Move left N places until board limit, piece in the way, or specified limit
      left.times do |i|
        next_pos = index - (i + 1)
        if unoccupied?(next_pos)
          valid << next_pos
        else
          valid << next_pos if piece_color(next_pos) == Move.enemy_color
          break
        end
      end

      valid
    end
Lateral movements (Left, Right, Up, Down). Will return all valid lateral movies for a piece at index
 By default, it will extend the piece movement laterally until it hits a board edge
 or until it hits a piece. This can be changed by passing the limit argument
 For example, the king can only move laterally 1 position, so it would pass limit=1