def transform_komabetsu_lines(lines)
      board = generate_empty_board
      hands = [
        { "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 },
        { "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 }
      ]
      all = { "FU" => 18, "KY" => 4, "KE" => 4, "GI" => 4, "KI" => 4, "KA" => 2, "HI" => 2 }

      lines.each do |line|
        line["pieces"].each do |piece|
          xy = piece["xy"]
          if xy["x"] == 0
            if piece["piece"] == "AL"
              hands[line["teban"]] = all
              return { "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
            end
            obj = hands[line["teban"]]
            obj[piece["piece"]] += 1
          else
            board[xy["x"] - 1][xy["y"] - 1] = { "color" => line["teban"],
                                                "kind" => piece["piece"] }
          end
          all[piece["piece"]] -= 1 if piece["piece"] != "OU"
        end
      end

      { "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
    end
def transform_komabetsu_lines(lines)
      board = generate_empty_board
      hands = [
        { "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 },
        { "FU" => 0, "KY" => 0, "KE" => 0, "GI" => 0, "KI" => 0, "KA" => 0, "HI" => 0 }
      ]
      all = { "FU" => 18, "KY" => 4, "KE" => 4, "GI" => 4, "KI" => 4, "KA" => 2, "HI" => 2 }

      lines.each do |line|
        line["pieces"].each do |piece|
          xy = piece["xy"]
          if xy["x"] == 0
            if piece["piece"] == "AL"
              hands[line["teban"]] = all
              return { "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
            end
            obj = hands[line["teban"]]
            obj[piece["piece"]] += 1
          else
            board[xy["x"] - 1][xy["y"] - 1] = { "color" => line["teban"],
                                                "kind" => piece["piece"] }
          end
          all[piece["piece"]] -= 1 if piece["piece"] != "OU"
        end
      end

      { "preset" => "OTHER", "data" => { "board" => board, "hands" => hands } }
    end
lines to jkf