feen 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -10
- data/lib/feen.rb +20 -28
- data/lib/feen/dumper.rb +16 -20
- data/lib/feen/dumper/in_hand.rb +23 -0
- data/lib/feen/dumper/{board.rb → square.rb} +3 -3
- data/lib/feen/dumper/turn.rb +3 -4
- data/lib/feen/parser.rb +15 -19
- data/lib/feen/parser/in_hand.rb +21 -0
- data/lib/feen/parser/{board.rb → square.rb} +3 -3
- metadata +6 -6
- data/lib/feen/dumper/pieces_in_hand.rb +0 -36
- data/lib/feen/parser/pieces_in_hand.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 730da5cc06535403835733403b2e86d03435337bd7cd36e5af2d47a1442f199f
|
4
|
+
data.tar.gz: f3a1b2a952dccbc9bb5eeb15dcfc920d3ea270abb301ed29c098da5260a4c3e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c001a2c2c8c7f88aba144ca878c45e11fde53b5c71ff3afa4caf8b05724d4a90dd6addfa32e29a4132b099818b4b6dd1dd0a55ab54b629af48b7113095d6cb54
|
7
|
+
data.tar.gz: 52f11c59367bc9d7dab6d21ad969cec1f7dd672f7fdab175f577d9076b7443e911b22b63c798198aae176f3939c4142f8eaa4cda1aa775464dbf0ba929f953ae
|
data/README.md
CHANGED
@@ -38,25 +38,22 @@ require "feen"
|
|
38
38
|
|
39
39
|
# Dump a classic Tsume Shogi problem
|
40
40
|
FEEN.dump(
|
41
|
+
"in_hand": %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p],
|
42
|
+
"shape": [9, 9],
|
41
43
|
"side_id": 0,
|
42
|
-
"
|
44
|
+
"square": {
|
43
45
|
3 => "s",
|
44
46
|
4 => "k",
|
45
47
|
5 => "s",
|
46
48
|
22 => "+P",
|
47
49
|
43 => "+B"
|
48
|
-
}
|
49
|
-
"indexes": [9, 9],
|
50
|
-
"hands": [
|
51
|
-
%w[S],
|
52
|
-
%w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
|
53
|
-
]
|
50
|
+
}
|
54
51
|
)
|
55
|
-
# => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S
|
52
|
+
# => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
56
53
|
|
57
54
|
# Parse a classic Tsume Shogi problem
|
58
|
-
FEEN.parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S
|
59
|
-
# => {:
|
55
|
+
FEEN.parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
|
56
|
+
# => {:square=>{3=>"s", 4=>"k", 5=>"s", 22=>"+P", 43=>"+B"}, :shape=>[9, 9], :in_hand=>["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"], :side_id=>0}
|
60
57
|
```
|
61
58
|
|
62
59
|
## License
|
data/lib/feen.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "feen
|
4
|
-
require_relative "feen
|
3
|
+
require_relative File.join("feen", "dumper")
|
4
|
+
require_relative File.join("feen", "parser")
|
5
5
|
|
6
6
|
# This module provides a Ruby interface for data serialization and
|
7
7
|
# deserialization in FEEN format.
|
@@ -10,37 +10,33 @@ require_relative "feen/parser"
|
|
10
10
|
module FEEN
|
11
11
|
# @example Dumps position params into a FEEN string.
|
12
12
|
#
|
13
|
+
# @param in_hand [Array] The list of pieces in hand.
|
14
|
+
# @param shape [Array] The shape of the board.
|
13
15
|
# @param side_id [Integer] The identifier of the player who must play.
|
14
|
-
# @param
|
15
|
-
# @param indexes [Array] The shape of the board.
|
16
|
-
# @param hands [Array] The list of pieces in hand
|
17
|
-
# grouped by players.
|
16
|
+
# @param square [Hash] The index of each piece on the board.
|
18
17
|
#
|
19
18
|
# @example Dump a classic Tsume Shogi problem
|
20
19
|
# dump(
|
20
|
+
# "in_hand": %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p],
|
21
|
+
# "shape": [9, 9],
|
21
22
|
# "side_id": 0,
|
22
|
-
# "
|
23
|
+
# "square": {
|
23
24
|
# 3 => "s",
|
24
25
|
# 4 => "k",
|
25
26
|
# 5 => "s",
|
26
27
|
# 22 => "+P",
|
27
28
|
# 43 => "+B"
|
28
|
-
# }
|
29
|
-
# "hands": [
|
30
|
-
# %w[S],
|
31
|
-
# %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
|
32
|
-
# ],
|
33
|
-
# "indexes": [9, 9]
|
29
|
+
# }
|
34
30
|
# )
|
35
|
-
# # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S
|
31
|
+
# # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
36
32
|
#
|
37
33
|
# @return [String] The FEEN string representing the position.
|
38
|
-
def self.dump(
|
34
|
+
def self.dump(in_hand:, shape:, side_id:, square:)
|
39
35
|
Dumper.call(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
in_hand: in_hand,
|
37
|
+
shape: shape,
|
38
|
+
side_id: side_id,
|
39
|
+
square: square
|
44
40
|
)
|
45
41
|
end
|
46
42
|
|
@@ -49,22 +45,18 @@ module FEEN
|
|
49
45
|
# @param feen [String] The FEEN string representing a position.
|
50
46
|
#
|
51
47
|
# @example Parse a classic Tsume Shogi problem
|
52
|
-
# parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S
|
48
|
+
# parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
|
53
49
|
# # => {
|
50
|
+
# # "in_hand": ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"],
|
51
|
+
# # "shape": [9, 9],
|
54
52
|
# # "side_id": 0,
|
55
|
-
# # "
|
53
|
+
# # "square": {
|
56
54
|
# # 3 => "s",
|
57
55
|
# # 4 => "k",
|
58
56
|
# # 5 => "s",
|
59
57
|
# # 22 => "+P",
|
60
58
|
# # 43 => "+B"
|
61
|
-
# # }
|
62
|
-
# # "hands": [
|
63
|
-
# # %w[S],
|
64
|
-
# # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
|
65
|
-
# # ],
|
66
|
-
# # "indexes": [9, 9]
|
67
|
-
# # }
|
59
|
+
# # }
|
68
60
|
#
|
69
61
|
# @return [Hash] The position params representing the position.
|
70
62
|
def self.parse(feen)
|
data/lib/feen/dumper.rb
CHANGED
@@ -1,44 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "dumper
|
4
|
-
require_relative "dumper
|
5
|
-
require_relative "dumper
|
3
|
+
require_relative File.join("dumper", "in_hand")
|
4
|
+
require_relative File.join("dumper", "square")
|
5
|
+
require_relative File.join("dumper", "turn")
|
6
6
|
|
7
7
|
module FEEN
|
8
8
|
# The dumper module.
|
9
9
|
module Dumper
|
10
10
|
# Dump position params into a FEEN string.
|
11
11
|
#
|
12
|
+
# @param in_hand [Array] The list of pieces in hand.
|
13
|
+
# @param shape [Array] The shape of the board.
|
12
14
|
# @param side_id [Integer] The identifier of the player who must play.
|
13
|
-
# @param
|
14
|
-
# @param indexes [Array] The shape of the board.
|
15
|
-
# @param hands [Array] The list of pieces in hand
|
16
|
-
# grouped by players.
|
15
|
+
# @param square [Hash] The index of each piece on the board.
|
17
16
|
#
|
18
17
|
# @example Dump a classic Tsume Shogi problem
|
19
18
|
# call(
|
20
|
-
# "
|
19
|
+
# "in_hand": %w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p],
|
20
|
+
# "shape": [9, 9],
|
21
|
+
# "side_id": 0,
|
22
|
+
# "square": {
|
21
23
|
# 3 => "s",
|
22
24
|
# 4 => "k",
|
23
25
|
# 5 => "s",
|
24
26
|
# 22 => "+P",
|
25
27
|
# 43 => "+B"
|
26
|
-
# }
|
27
|
-
# "hands": [
|
28
|
-
# %w[S],
|
29
|
-
# %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
|
30
|
-
# ],
|
31
|
-
# "indexes": [9, 9],
|
32
|
-
# "side_id": 0
|
28
|
+
# }
|
33
29
|
# )
|
34
|
-
# # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S
|
30
|
+
# # => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
35
31
|
#
|
36
32
|
# @return [String] The FEEN string representing the position.
|
37
|
-
def self.call(
|
33
|
+
def self.call(in_hand:, shape:, side_id:, square:)
|
38
34
|
[
|
39
|
-
|
40
|
-
Turn.dump(side_id
|
41
|
-
|
35
|
+
Square.new(shape, square).to_s,
|
36
|
+
Turn.dump(side_id),
|
37
|
+
InHand.dump(in_hand)
|
42
38
|
].join(" ")
|
43
39
|
end
|
44
40
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FEEN
|
4
|
+
module Dumper
|
5
|
+
# The pieces in hand class.
|
6
|
+
#
|
7
|
+
# @example Serialize a list of pieces in hand grouped by sides
|
8
|
+
# PiecesInHand.dump(%w[S r r b g g g g s n n n n p p p p p p p p p p p p p p p p p])
|
9
|
+
# # => "S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
10
|
+
module InHand
|
11
|
+
# Serialize pieces in hand lists into a string.
|
12
|
+
#
|
13
|
+
# @param piece_names [Array] A list of pieces in hand.
|
14
|
+
#
|
15
|
+
# @return [String] A string representing the pieces in hand.
|
16
|
+
def self.dump(piece_names)
|
17
|
+
return "-" if piece_names.empty?
|
18
|
+
|
19
|
+
piece_names.sort.join("/")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module FEEN
|
4
4
|
module Dumper
|
5
|
-
# The
|
5
|
+
# The square class.
|
6
6
|
#
|
7
7
|
# @example Dump an empty board of Xiangqi
|
8
8
|
# Board.new([10, 9]).to_s # => "9/9/9/9/9/9/9/9/9/9"
|
@@ -45,9 +45,9 @@ module FEEN
|
|
45
45
|
# 89 => "俥"
|
46
46
|
# }
|
47
47
|
# ).to_s # => "車,馬,象,士,將,士,象,馬,車/9/1,砲,5,砲,1/卒,1,卒,1,卒,1,卒,1,卒/9/9/兵,1,兵,1,兵,1,兵,1,兵/1,炮,5,炮,1/9/俥,傌,相,仕,帥,仕,相,傌,俥"
|
48
|
-
class
|
48
|
+
class Square
|
49
49
|
# @param indexes [Array] The shape of the board.
|
50
|
-
# @param board [Hash] The
|
50
|
+
# @param board [Hash] The index of each piece on the board.
|
51
51
|
def initialize(indexes, board)
|
52
52
|
@indexes = indexes
|
53
53
|
@squares = Array.new(length) { |i| board.fetch(i, nil) }
|
data/lib/feen/dumper/turn.rb
CHANGED
@@ -5,14 +5,13 @@ module FEEN
|
|
5
5
|
# The turn module.
|
6
6
|
module Turn
|
7
7
|
# @param side_id [Integer] The identifier of the active player.
|
8
|
-
# @param sides_count [Integer] The number of players.
|
9
8
|
#
|
10
9
|
# @example Dump the number that identify the player who have to play
|
11
|
-
# dump(0
|
10
|
+
# dump(0) # => "0"
|
12
11
|
#
|
13
12
|
# @return [String] The number that identify the player who have to play.
|
14
|
-
def self.dump(side_id
|
15
|
-
String(
|
13
|
+
def self.dump(side_id)
|
14
|
+
String(side_id)
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
data/lib/feen/parser.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "parser
|
4
|
-
require_relative "parser
|
5
|
-
require_relative "parser
|
6
|
-
require_relative "parser
|
3
|
+
require_relative File.join("parser", "in_hand")
|
4
|
+
require_relative File.join("parser", "shape")
|
5
|
+
require_relative File.join("parser", "square")
|
6
|
+
require_relative File.join("parser", "turn")
|
7
7
|
|
8
8
|
module FEEN
|
9
9
|
# The parser module.
|
@@ -13,32 +13,28 @@ module FEEN
|
|
13
13
|
# @param feen [String] The FEEN string representing a position.
|
14
14
|
#
|
15
15
|
# @example Parse a classic Tsume Shogi problem
|
16
|
-
# call("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S
|
16
|
+
# call("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
|
17
17
|
# # => {
|
18
|
-
# # "
|
18
|
+
# # "in_hand": ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"],
|
19
|
+
# # "shape": [9, 9],
|
20
|
+
# # "side_id": 0,
|
21
|
+
# # "square": {
|
19
22
|
# # 3 => "s",
|
20
23
|
# # 4 => "k",
|
21
24
|
# # 5 => "s",
|
22
25
|
# # 22 => "+P",
|
23
26
|
# # 43 => "+B"
|
24
|
-
# # }
|
25
|
-
# # "hands": [
|
26
|
-
# # %w[S],
|
27
|
-
# # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
|
28
|
-
# # ],
|
29
|
-
# # "indexes": [9, 9],
|
30
|
-
# # "side_id": 0
|
31
|
-
# # }
|
27
|
+
# # }
|
32
28
|
#
|
33
29
|
# @return [Hash] The position params representing the position.
|
34
30
|
def self.call(feen)
|
35
|
-
|
31
|
+
square_str, side_id_str, in_hand_str = feen.split(" ")
|
36
32
|
|
37
33
|
{
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
in_hand: InHand.parse(in_hand_str),
|
35
|
+
shape: Shape.new(square_str).to_a,
|
36
|
+
side_id: Turn.parse(side_id_str),
|
37
|
+
square: Square.new(square_str).to_h
|
42
38
|
}
|
43
39
|
end
|
44
40
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FEEN
|
4
|
+
module Parser
|
5
|
+
# The pieces in hand module.
|
6
|
+
module InHand
|
7
|
+
# The list of pieces in hand grouped by players.
|
8
|
+
#
|
9
|
+
# @param piece_names_str [String] The serialized list of pieces in hand.
|
10
|
+
#
|
11
|
+
# @example Parse a list of serialized pieces in hand
|
12
|
+
# parse("S,b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
|
13
|
+
# # => ["S", "b", "g", "g", "g", "g", "n", "n", "n", "n", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "p", "r", "r", "s"]
|
14
|
+
#
|
15
|
+
# @return [Array] The list of pieces in hand grouped by players.
|
16
|
+
def self.parse(piece_names_str)
|
17
|
+
piece_names_str.split(",")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module FEEN
|
4
4
|
module Parser
|
5
|
-
# The
|
5
|
+
# The square class.
|
6
6
|
#
|
7
7
|
# @example Parse a Shogi problem board and return an array
|
8
8
|
# Board.new("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9").to_a
|
@@ -27,7 +27,7 @@ module FEEN
|
|
27
27
|
# # 22 => "+P",
|
28
28
|
# # 43 => "+B"
|
29
29
|
# # }
|
30
|
-
class
|
30
|
+
class Square
|
31
31
|
# @param board [String] The flatten board.
|
32
32
|
def initialize(board)
|
33
33
|
@board = board
|
@@ -40,7 +40,7 @@ module FEEN
|
|
40
40
|
.flat_map { |str| row(str) }
|
41
41
|
end
|
42
42
|
|
43
|
-
# @return [Hash] The
|
43
|
+
# @return [Hash] The index of each piece on the board.
|
44
44
|
def to_h
|
45
45
|
to_a
|
46
46
|
.each_with_index
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brutal
|
@@ -132,13 +132,13 @@ files:
|
|
132
132
|
- README.md
|
133
133
|
- lib/feen.rb
|
134
134
|
- lib/feen/dumper.rb
|
135
|
-
- lib/feen/dumper/
|
136
|
-
- lib/feen/dumper/
|
135
|
+
- lib/feen/dumper/in_hand.rb
|
136
|
+
- lib/feen/dumper/square.rb
|
137
137
|
- lib/feen/dumper/turn.rb
|
138
138
|
- lib/feen/parser.rb
|
139
|
-
- lib/feen/parser/
|
140
|
-
- lib/feen/parser/pieces_in_hand.rb
|
139
|
+
- lib/feen/parser/in_hand.rb
|
141
140
|
- lib/feen/parser/shape.rb
|
141
|
+
- lib/feen/parser/square.rb
|
142
142
|
- lib/feen/parser/turn.rb
|
143
143
|
homepage: https://developer.sashite.com/specs/forsyth-edwards-expanded-notation
|
144
144
|
licenses:
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FEEN
|
4
|
-
module Dumper
|
5
|
-
# The pieces in hand class.
|
6
|
-
#
|
7
|
-
# @example Serialize a list of pieces in hand grouped by sides
|
8
|
-
# PiecesInHand.dump(
|
9
|
-
# %w[S],
|
10
|
-
# %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
|
11
|
-
# )
|
12
|
-
# # => "S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"
|
13
|
-
class PiecesInHand
|
14
|
-
# Serialize pieces in hand lists into a string.
|
15
|
-
#
|
16
|
-
# @param hands [Array] The list of pieces in hand
|
17
|
-
# grouped by players.
|
18
|
-
#
|
19
|
-
# @return [String] A string representing the pieces in hand of both
|
20
|
-
# players.
|
21
|
-
def self.dump(hands)
|
22
|
-
hands.map { |pieces| new(pieces).to_s }.join("/")
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param pieces [Array] A list of pieces in hand.
|
26
|
-
def initialize(pieces)
|
27
|
-
@pieces = pieces.sort
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [String] A string representing the pieces in hand.
|
31
|
-
def to_s
|
32
|
-
@pieces.join(",")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FEEN
|
4
|
-
module Parser
|
5
|
-
# The pieces in hand module.
|
6
|
-
module PiecesInHand
|
7
|
-
# The list of pieces in hand grouped by players.
|
8
|
-
#
|
9
|
-
# @param hands_str [String] The serialized list of
|
10
|
-
# pieces in hand grouped by players.
|
11
|
-
#
|
12
|
-
# @example Parse a list of serialized pieces in hand
|
13
|
-
# parse("S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
|
14
|
-
# # => [
|
15
|
-
# # %w[S],
|
16
|
-
# # %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
|
17
|
-
# # ]
|
18
|
-
#
|
19
|
-
# @return [Array] The list of pieces in hand grouped by players.
|
20
|
-
def self.parse(hands_str)
|
21
|
-
hands_str
|
22
|
-
.split("/", -1)
|
23
|
-
.map { |pieces_in_hand_str| pieces_in_hand_str.split(",") }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|