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 first_piece(from, direction)
      file, rank = from
      i,    j    = direction
      piece = nil
      while valid_square?(file += i, rank += j)
        break if piece = self.board.at(file, rank)
      end
      [piece, [file, rank]]
    end
def first_piece ( from , direction ) file , rank = from i , j = direction piece = nil while valid_square? ( file += i , rank += j ) break if piece = self . board . at ( file , rank ) end [ piece , [ file , rank ] ] 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 .
from
<not_specific>
direction
<not_specific>