Sha256: 4c4203c7348ced62ef6de3f55583e82a8ba7fe365f72892179a369042245958a

Contents?: true

Size: 1.89 KB

Versions: 10

Compression:

Stored size: 1.89 KB

Contents

require "shogi/piece/base"

module Shogi
  module Piece
    MOVEMENTS_KI = [[ 0,  1],
                    [-1,  1],
                    [ 1,  1],
                    [-1,  0],
                    [ 1,  0],
                    [ 0, -1]]

    class TO < Base
      CSA_NAME = "TO"
      USI_NAME = "+P"
      MOVEMENTS = MOVEMENTS_KI
      CHILD = "FU"

      def initialize
        super(CSA_NAME, USI_NAME, MOVEMENTS)
      end
    end

    class NY < Base
      CSA_NAME = "NY"
      USI_NAME = "+L"
      MOVEMENTS = MOVEMENTS_KI
      CHILD = "KY"

      def initialize
        super(CSA_NAME, USI_NAME, MOVEMENTS)
      end
    end

    class NK < Base
      CSA_NAME = "NK"
      USI_NAME = "+N"
      MOVEMENTS = MOVEMENTS_KI
      CHILD = "KE"

      def initialize
        super(CSA_NAME, USI_NAME, MOVEMENTS)
      end
    end

    class NG < Base
      CSA_NAME = "NG"
      USI_NAME = "+S"
      MOVEMENTS = MOVEMENTS_KI
      CHILD = "GI"

      def initialize
        super(CSA_NAME, USI_NAME, MOVEMENTS)
      end
    end

    class UM < Base
      CSA_NAME = "UM"
      USI_NAME = "+B"
      MOVEMENTS = [(-8..-1).collect {|a| [a,  a] },
                   ( 1.. 8).collect {|a| [a,  a] },
                   (-8..-1).collect {|a| [a, -a] },
                   ( 1.. 8).collect {|a| [a, -a] },
                   [[-1, 0], [0, -1], [0, 1], [1, 0]]].flatten(1)
      CHILD = "KA"

      def initialize
        super(CSA_NAME, USI_NAME, MOVEMENTS)
      end
    end

    class RY < Base
      CSA_NAME = "RY"
      USI_NAME = "+R"
      MOVEMENTS = [(-8..-1).collect {|h| [0, h] },
                   ( 1.. 8).collect {|h| [0, h] },
                   (-8..-1).collect {|w| [w, 0] },
                   ( 1.. 8).collect {|w| [w, 0] },
                   [[-1, -1], [-1, 1], [1, -1], [1, 1]]].flatten(1)
      CHILD = "HI"

      def initialize
        super(CSA_NAME, USI_NAME, MOVEMENTS)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shogi-ruby-0.1.0 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.9 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.8 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.7 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.6 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.5 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.4 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.3 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.2 lib/shogi/piece/promoter.rb
shogi-ruby-0.0.1 lib/shogi/piece/promoter.rb