piece,promoted,pointのセットをHashで持ち歩くのをやめてMiniSoldierクラス化

diff --git a/README.org b/README.org
index 01e05fa..761d890 100644
--- a/README.org
+++ b/README.org
@@ -523,7 +523,7 @@
     | 相対座標 | vector   |
     | 先手     | black    |
     | 後手     | white    |
-    | 対局室   | mediator    |
+    | 対局室   | mediator |

 ** BUG

@@ -533,7 +533,6 @@

    - 手の候補を表示する
    - mediator の元を mediator にする
-   - board と player に mediator を【常に】渡す
    - @board が独立して marshal_dump/load できないから面倒なことになる。board 単体で push pop できるようにする → 設計ミス。player.sandbox_for しているのが間違い。mediator.sandbox_for なら辻褄があう。やっぱり @board はコピーできるようにする。
    - @board を複製できるようにする
    - DSLに rem(仮) 追加
@@ -556,6 +555,7 @@
    - Windowsブリッジ
    - GUI表示
    - cli
+   - +board と player に mediator を【常に】渡す+
    - +5x5将棋配置+
    - +BUG:"1一と成(12)" +
    - +「２三銀直不成」対応+
diff --git a/brawser/brawser.rb b/brawser/brawser.rb
index 072571e..ac97bc4 100644
--- a/brawser/brawser.rb
+++ b/brawser/brawser.rb
@@ -68,7 +68,7 @@ class Brawser < Sinatra::Base
     dump = Marshal.load(REDIS.get(@session_id))
     @mediator = Bushido::Mediator.from_dump(dump)

-    if params[:location].blank? || @mediator.current_player.location.key.to_s == params[:location]
+    if params[:location].nil? || @mediator.current_player.location.key.to_s == params[:location]
       if params[:way].present?
         @mediator.execute(params[:way])
       end
@@ -100,7 +100,7 @@ class Brawser < Sinatra::Base
   get "/board_points" do
     session[:test_count] ||= 0
     session[:start_time] ||= Time.now
-    if params[:count].blank?
+    unless params[:count]
       session[:test_count] = 0
       session[:start_time] = Time.now
     end
@@ -109,8 +109,8 @@ class Brawser < Sinatra::Base
     begin
       @mediator = Bushido::Mediator.start
       count.times do
-        arg = {:point => Bushido::Point.to_a.sample, :piece => Bushido::Piece.to_a.sample, :promoted => [true, false].sample}
-        @mediator.players.sample.initial_soldiers(arg, :from_piece => false)
+        sinfo = {:point => Bushido::Point.to_a.sample, :piece => Bushido::Piece.to_a.sample, :promoted => [true, false].sample}
+        @mediator.players.sample.initial_soldiers(sinfo, :from_piece => false)
       end
     rescue Bushido::NotPutInPlaceNotBeMoved, Bushido::NotPromotable, Bushido::PieceAlredyExist => error
       retry
diff --git a/brawser/views/effective_patterns.haml b/brawser/views/effective_patterns.haml
index 36e9ba8..22fecb0 100644
--- a/brawser/views/effective_patterns.haml
+++ b/brawser/views/effective_patterns.haml
@@ -9,7 +9,7 @@
   %div= @pattern[:title]
   %div
     = @pattern[:comment]
-    - if @pattern[:url].present?
+    - if @pattern[:url]
       %a{href: @pattern[:url]}= "参考URL"
   .hr
   - @frames.each do |mediator|
diff --git a/lib/bushido.rb b/lib/bushido.rb
index 1d63a36..247f541 100644
--- a/lib/bushido.rb
+++ b/lib/bushido.rb
@@ -38,6 +38,9 @@ module Bushido
   class RuleError < SyntaxError; end
   class HistroyStackEmpty < SyntaxError; end

+  # 盤面定義のエラー
+  class BoardIsBlackOnly < SyntaxError; end
+
   # 構文エラーから発生する継続が難しいエラー
   class PositionSyntaxError < SyntaxError; end
   class PointSyntaxError < SyntaxError; end
diff --git a/lib/bushido/player.rb b/lib/bushido/player.rb
index b402b64..814fe44 100644
--- a/lib/bushido/player.rb
+++ b/lib/bushido/player.rb
@@ -106,7 +106,7 @@ module Bushido

     # 平手の初期配置
     def piece_plot
-      Utils.initial_side_placements_for(location).each{|info|
+      Utils.location_soldiers(location).each{|info|
         pick_out(info[:piece])
         soldier = Soldier.new(info.merge(:player => self))
         put_on_with_valid(info[:point], soldier)
@@ -119,24 +119,24 @@ module Bushido
     #   player.initial_soldiers(["５五飛", "３三飛"], :from_piece => false)
     #   player.initial_soldiers("#{point}馬")
     #   player.initial_soldiers({:point => point, :piece => Piece["角"], :promoted => true}, :from_piece => false)
-    def initial_soldiers(arg, options = {})
+    def initial_soldiers(sinfo_or_str, options = {})
       options = {
         :from_piece => true, # 持駒から配置する？
       }.merge(options)
-      Array.wrap(arg).each{|arg|
-        if Hash === arg
-          info = arg
+      Array.wrap(sinfo_or_str).each{|sinfo_or_str|
+        if Hash === sinfo_or_str
+          sinfo = sinfo_or_str
         else
-          if arg.to_s.gsub(/_/, "").blank? # テストを書きやすくするため
+          if sinfo_or_str.to_s.gsub(/_/, "").empty? # テストを書きやすくするため
             next
           end
-          info = Utils.parse_str(arg)
+          sinfo = Utils.parse_str(sinfo_or_str)
         end
         if options[:from_piece]
-          pick_out(info[:piece]) # 持駒から引くだけでそのオブジェクトを打つ必要はない
+          pick_out(sinfo[:piece]) # 持駒から引くだけでそのオブジェクトを打つ必要はない
         end
-        soldier = Soldier.new(info.merge(:player => self))
-        put_on_with_valid(info[:point], soldier)
+        soldier = Soldier.new(sinfo.merge(:player => self))
+        put_on_with_valid(sinfo[:point], soldier)
         @soldiers << soldier
       }
     end
@@ -342,7 +342,7 @@ module Bushido

         # ここがかなり重い
         libs.find_all{|k, v|v[:defense_p]}.collect{|key, value|
-          placements = Utils.initial_side_placements_for2(location, value[:board])
+          placements = Utils.location_soldiers_from_char_board(location, value[:board])

           a = placements.collect{|e|Utils.sinfo_to_s(e)}
           b = @soldiers.collect(&:to_h).collect{|e|Utils.sinfo_to_s(e)}
@@ -372,17 +372,17 @@ module Bushido
         yield self
       end
       marshal_load(_save)
-      # info = Utils.parse_str(arg)
-      # _soldier = Soldier.new(info.merge(:player => self))
-      # get_errors(info[:point], info[:piece], info[:promoted]).each{|error|raise error}
+      # sinfo = Utils.parse_str(arg)
+      # _soldier = Soldier.new(sinfo.merge(:player => self))
+      # get_errors(sinfo[:point], sinfo[:piece], sinfo[:promoted]).each{|error|raise error}
       # begin
       #   @soldiers << _soldier
-      #   put_on_with_valid(info[:point], soldier)
+      #   put_on_with_valid(sinfo[:point], soldier)
       #   if block
       #     yield soldier
       #   end
       # ensure
-      #   soldier = board.pick_up!(info[:point])
+      #   soldier = board.pick_up!(sinfo[:point])
       #   @pieces << _soldier.piece
       #   @soldiers.pop
       # end
diff --git a/lib/bushido/utils.rb b/lib/bushido/utils.rb
index 90a61ba..34f9980 100644
--- a/lib/bushido/utils.rb
+++ b/lib/bushido/utils.rb
@@ -15,33 +15,33 @@ module Bushido
       Piece.parse!(md[:piece]).merge(:point => Point.parse(md[:point]))
     end

-    # 指定プレイヤー側の初期配置
-    #   Utils.initial_side_placements_for(:black, "平手") # => ["9七歩", "8七歩", ...]
-    #   Utils.initial_side_placements_for(:black, "角落ち") # => [...]
-    #   Utils.initial_side_placements_for(:black, "+----+\n|...") # => [...]
-    def initial_side_placements_for(location, name = nil)
-      name = name.presence || "平手"
-      if BaseFormat.board_string?(name)
-        board_aa = name
-      else
-        # board_aa = BoardLibs.fetch(name.presence || "平手")
-        board_aa = BoardLibs.fetch(name)[:board]
+    # ハッシュにした駒を人間が入力する表記に戻す
+    #   Utils.sinfo_to_s(Utils.parse_str("４二竜")) # => "４二竜"
+    def sinfo_to_s(sinfo)
+      "#{sinfo[:point].name}#{sinfo[:piece].some_name(sinfo[:promoted])}"
+    end

+    # 指定プレイヤー側の初期配置(「角落ち」などを指定可)
+    #   Utils.location_soldiers(:black, "平手")         # => ["9七歩", "8七歩", ...]
+    #   Utils.location_soldiers(:black, "角落ち")       # => ["9七歩", "8七歩", ...]
+    #   Utils.location_soldiers(:black, "+----+\n|...") # => [...]
+    def location_soldiers(location, name_or_char_board = nil)
+      name_or_char_board = name_or_char_board.presence || "平手"
+      if BaseFormat.board_string?(name_or_char_board)
+        char_board = name_or_char_board
+      else
+        char_board = BoardLibs.fetch(name_or_char_board)[:board]
       end
-      # puts board_aa
-      initial_side_placements_for2(location, board_aa)
+      location_soldiers_from_char_board(location, char_board)
     end

-    def initial_side_placements_for2(location, board_aa)
-      # puts board_aa
-      initial_placements = BaseFormat.board_parse(board_aa)
-
+    # 指定プレイヤー側の初期配置(盤面のみ対応)
+    #   Utils.location_soldiers(:black, "+----+\n|...") # => [...]
+    def location_soldiers_from_char_board(location, char_board)
+      initial_placements = BaseFormat.board_parse(char_board)
       if initial_placements[:white].present?
-        raise SyntaxError, "先手側から見たデータを反転して使うのでここでは後手のデータは定義できません : #{board_aa}"
+        raise BoardIsBlackOnly, "後手側データは定義できません : #{char_board}"
       end
-
-      # p initial_placements
-
       initial_placements[:black].collect do |arg|
         info = Utils.parse_str(arg)
         info[:point] = info[:point].as_location(location)
@@ -49,10 +49,6 @@ module Bushido
       end
     end

-    def sinfo_to_s(sinfo)
-      "#{sinfo[:point].name}#{sinfo[:piece].some_name(sinfo[:promoted])}"
-    end
-
     # 要テスト
     #   board_init_type("+-----")                              # そのまま棋譜が入ってれいばそのままパース
     #   board_init_type("角落ち")                              # 先手だけが角落ち(下と同じ)
@@ -61,7 +57,7 @@ module Bushido
     def board_init_type(value = nil)
       if Hash === value
         # {"先手" => "角落ち", "後手" => "香落ち"}
-        value.inject({}){|hash, (k, v)|hash.merge(k => Utils.initial_side_placements_for(k, v))}
+        value.inject({}){|hash, (k, v)|hash.merge(k => Utils.location_soldiers(k, v))}
       elsif BaseFormat.board_string?(value)
         BaseFormat.board_parse(value)
       else
diff --git a/spec/utils_spec.rb b/spec/utils_spec.rb
index 5867a99..3f741a7 100644
--- a/spec/utils_spec.rb
+++ b/spec/utils_spec.rb
@@ -23,8 +23,8 @@ module Bushido
     end

     it "先手か後手かを指定した初期配置" do
-      Utils.initial_side_placements_for(:white, "平手")
-      Utils.initial_side_placements_for(:white, "角落ち")
+      Utils.location_soldiers(:white, "平手")
+      Utils.location_soldiers(:white, "角落ち")
     end
   end
 end