lib/pgn/move_calculator.rb
# Specifies the movement of pieces who are allowed to move in a
# given direction until they reach an obstacle or the end of the
# board.
#
Specifies the movement of pieces who are allowed to move in a
given direction until they reach an obstacle or the end of the
board.
Specifies the movement of pieces who are allowed to move in a given direction until they reach an obstacle or the end of the board .
def king_position
      king = self.move.white? ? 'K' : 'k'
      coords = nil
      0.upto(7) do |file|
        0.upto(7) do |rank|
          if self.board.at(file, rank) == king
            coords = [file, rank]
          end
        end
      end
      coords
    end
def king_position king = self . move . white? ? 'K' : 'k' coords = nil 0 . upto ( 7 ) do | file | 0 . upto ( 7 ) do | rank | if self . board . at ( file , rank ) == king coords = [ file , rank ] end end end coords end
Specifies the movement of pieces who are allowed to move in a
given direction until they reach an obstacle or the end of the
board.
Specifies the movement of pieces who are allowed to move in a given direction until they reach an obstacle or the end of the board .