Sha256: 8a89c9d8d8be07946d8a2a312f9001b3be5e42a0316b7f383d0234dc07a88efb

Contents?: true

Size: 860 Bytes

Versions: 2

Compression:

Stored size: 860 Bytes

Contents

module Shogi
  module Format
    module USI
      module Board
        def to_usi
          @table.map {|row|
            usi_row = ""
            space_count = 0
            row.each do |cell|
              if cell == ""
                space_count += 1
              else
                if space_count > 0
                  usi_row << space_count.to_s
                  space_count = 0
                end
                usi = Piece.const_get(cell[1..2]).new.usi
                if cell[0] == "-"
                  usi_row << usi.downcase
                else
                  usi_row << usi
                end
              end
            end
            if space_count > 0
              usi_row << space_count.to_s
              space_count = 0
            end
            usi_row
          }.join("/") << "\n"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shogi-ruby-0.0.9 lib/shogi/format/usi/board.rb
shogi-ruby-0.0.8 lib/shogi/format/usi/board.rb