lib/pgn2fen.rb
##
# make a ply on the board
make a ply on the board
make a ply on the board
def make_ply_on_board(long_ply)
      from_pgn = long_ply[0,2] 
      to_pgn = long_ply[2,2] 
      from_idx = @@pgn_number_hash[from_pgn]
      to_idx = @@pgn_number_hash[to_pgn]
      if @promotion
        if "P" == @board[from_idx] 
          @board[to_idx] = @promotion_piece.upcase
        else 
          @board[to_idx] = @promotion_piece.downcase
        end
        @promotion = false
        @promotion_piece = nil
      else 
        @board[to_idx] = @board[from_idx]
      end
      @board[from_idx] = ""
    end
def make_ply_on_board ( long_ply ) from_pgn = long_ply [ 0 , 2 ] to_pgn = long_ply [ 2 , 2 ] from_idx = @@pgn_number_hash [ from_pgn ] to_idx = @@pgn_number_hash [ to_pgn ] if @promotion if "P" == @board [ from_idx ] @board [ to_idx ] = @promotion_piece . upcase else @board [ to_idx ] = @promotion_piece . downcase end @promotion = false @promotion_piece = nil else @board [ to_idx ] = @board [ from_idx ] end @board [ from_idx ] = "" end
make a ply on the board
make a ply on the board
#puts "from_pgn:#{from_pgn}, to_pgn:#{to_pgn}, from_idx:#{from_idx}, to_idx:#{to_idx}" #white #black #general case
long_ply
<not_specific>