bioshogi 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -8
- data/README.org +1 -1
- data/bin/bioshogi +1 -1
- data/lib/bioshogi/ai/brain.rb +35 -11
- data/lib/bioshogi/ai/diver/base.rb +1 -1
- data/lib/bioshogi/ai/diver/nega_alpha_diver.rb +1 -1
- data/lib/bioshogi/ai/diver/nega_alpha_mate_diver.rb +1 -1
- data/lib/bioshogi/ai/diver/nega_max_diver.rb +1 -1
- data/lib/bioshogi/ai/diver/nega_scout_diver.rb +1 -1
- data/lib/bioshogi/ai/evaluator/attack_weight_table.rb +1 -1
- data/lib/bioshogi/ai/evaluator/base.rb +1 -1
- data/lib/bioshogi/ai/evaluator/level0.rb +1 -1
- data/lib/bioshogi/ai/evaluator/level1.rb +1 -1
- data/lib/bioshogi/ai/evaluator/level2.rb +1 -1
- data/lib/bioshogi/ai/evaluator/level3.rb +1 -1
- data/lib/bioshogi/ai/evaluator/level4.rb +1 -1
- data/lib/bioshogi/ai/evaluator/opening_basic_table.rb +1 -1
- data/lib/bioshogi/ai/player_brain_mod.rb +1 -1
- data/lib/bioshogi/ai/versus.rb +91 -0
- data/lib/bioshogi/ai.rb +1 -1
- data/lib/bioshogi/assets/kifu_formats/sample.csa +132 -0
- data/lib/bioshogi/assets/kifu_formats/sample.ki2 +29 -0
- data/lib/bioshogi/assets/kifu_formats/sample.kif +123 -0
- data/lib/bioshogi/assets/kifu_formats/sample.sfen +1 -0
- data/lib/bioshogi/cli/input_checker.rb +21 -0
- data/lib/bioshogi/cli/piece.rb +15 -8
- data/lib/bioshogi/cli.rb +6 -92
- data/lib/bioshogi/converter.rb +56 -0
- data/lib/bioshogi/extreme_validator.rb +1 -1
- data/lib/bioshogi/formatter/animation/demo_builder.rb +1 -1
- data/lib/bioshogi/input_parser.rb +7 -0
- data/lib/bioshogi/player.rb +1 -1
- data/lib/bioshogi/version.rb +1 -1
- data/lib/bioshogi.rb +48 -33
- metadata +10 -6
- data/lib/bioshogi/cli/convert.rb +0 -34
- data/lib/bioshogi/cli/input_parser.rb +0 -23
- data/lib/bioshogi/cli/versus.rb +0 -160
@@ -0,0 +1,123 @@
|
|
1
|
+
開始日時:2017/11/11 10:00:00
|
2
|
+
終了日時:2017/11/11 17:22:00
|
3
|
+
棋戦:女流王座戦
|
4
|
+
場所:大阪・芝苑
|
5
|
+
手合割:平手
|
6
|
+
先手:加藤桃子 女王
|
7
|
+
後手:里見香奈 女流王座
|
8
|
+
戦型:ゴキゲン中飛車
|
9
|
+
手数----指手---------消費時間--
|
10
|
+
1 2六歩(27) (00:00/00:00:00)
|
11
|
+
2 3四歩(33) (00:00/00:00:00)
|
12
|
+
3 2五歩(26) (00:00/00:00:00)
|
13
|
+
4 3三角(22) (00:00/00:00:00)
|
14
|
+
5 7六歩(77) (00:00/00:00:00)
|
15
|
+
6 4二銀(31) (00:00/00:00:00)
|
16
|
+
7 4八銀(39) (00:00/00:00:00)
|
17
|
+
8 5四歩(53) (00:00/00:00:00)
|
18
|
+
9 6八玉(59) (00:00/00:00:00)
|
19
|
+
10 5五歩(54) (00:00/00:00:00)
|
20
|
+
11 3六歩(37) (00:00/00:00:00)
|
21
|
+
12 5二飛(82) (00:00/00:00:00)
|
22
|
+
13 3七銀(48) (00:00/00:00:00)
|
23
|
+
14 5三銀(42) (00:00/00:00:00)
|
24
|
+
15 4六銀(37) (00:00/00:00:00)
|
25
|
+
16 4四銀(53) (00:00/00:00:00)
|
26
|
+
17 5八金(49) (00:00/00:00:00)
|
27
|
+
18 6二玉(51) (00:00/00:00:00)
|
28
|
+
19 7八玉(68) (00:00/00:00:00)
|
29
|
+
20 7二玉(62) (00:00/00:00:00)
|
30
|
+
21 6六歩(67) (00:00/00:00:00)
|
31
|
+
22 8二玉(72) (00:00/00:00:00)
|
32
|
+
23 6七金(58) (00:00/00:00:00)
|
33
|
+
24 7二銀(71) (00:00/00:00:00)
|
34
|
+
25 7七角(88) (00:00/00:00:00)
|
35
|
+
26 9四歩(93) (00:00/00:00:00)
|
36
|
+
27 8八玉(78) (00:00/00:00:00)
|
37
|
+
28 9五歩(94) (00:00/00:00:00)
|
38
|
+
29 9八香(99) (00:00/00:00:00)
|
39
|
+
30 8四歩(83) (00:00/00:00:00)
|
40
|
+
31 9九玉(88) (00:00/00:00:00)
|
41
|
+
32 8三銀(72) (00:00/00:00:00)
|
42
|
+
33 8八銀(79) (00:00/00:00:00)
|
43
|
+
34 7二金(61) (00:00/00:00:00)
|
44
|
+
35 6五歩(66) (00:00/00:00:00)
|
45
|
+
36 7四歩(73) (00:00/00:00:00)
|
46
|
+
37 6六金(67) (00:00/00:00:00)
|
47
|
+
38 7三桂(81) (00:00/00:00:00)
|
48
|
+
39 8六角(77) (00:00/00:00:00)
|
49
|
+
40 5一飛(52) (00:00/00:00:00)
|
50
|
+
41 7八飛(28) (00:00/00:00:00)
|
51
|
+
42 8五歩(84) (00:00/00:00:00)
|
52
|
+
43 5九角(86) (00:00/00:00:00)
|
53
|
+
44 4二角(33) (00:00/00:00:00)
|
54
|
+
45 7九金(69) (00:00/00:00:00)
|
55
|
+
46 3三桂(21) (00:00/00:00:00)
|
56
|
+
47 7五歩(76) (00:00/00:00:00)
|
57
|
+
48 同歩(74) (00:00/00:00:00)
|
58
|
+
49 同金(66) (00:00/00:00:00)
|
59
|
+
50 同角(42) (00:00/00:00:00)
|
60
|
+
51 同飛(78) (00:00/00:00:00)
|
61
|
+
52 7四歩打 (00:00/00:00:00)
|
62
|
+
53 7六飛(75) (00:00/00:00:00)
|
63
|
+
54 7五金打 (00:00/00:00:00)
|
64
|
+
55 7八飛(76) (00:00/00:00:00)
|
65
|
+
56 5六歩(55) (00:00/00:00:00)
|
66
|
+
57 同歩(57) (00:00/00:00:00)
|
67
|
+
58 6五金(75) (00:00/00:00:00)
|
68
|
+
59 5五歩(56) (00:00/00:00:00)
|
69
|
+
60 5六歩打 (00:00/00:00:00)
|
70
|
+
61 2六角(59) (00:00/00:00:00)
|
71
|
+
62 1四歩(13) (00:00/00:00:00)
|
72
|
+
63 6二歩打 (00:00/00:00:00)
|
73
|
+
64 5二金(41) (00:00/00:00:00)
|
74
|
+
65 6一歩成(62) (00:00/00:00:00)
|
75
|
+
66 同飛(51) (00:00/00:00:00)
|
76
|
+
67 5四歩(55) (00:00/00:00:00)
|
77
|
+
68 6六金(65) (00:00/00:00:00)
|
78
|
+
69 6八飛(78) (00:00/00:00:00)
|
79
|
+
70 7六金(66) (00:00/00:00:00)
|
80
|
+
71 7七歩打 (00:00/00:00:00)
|
81
|
+
72 7五金(76) (00:00/00:00:00)
|
82
|
+
73 5八飛(68) (00:00/00:00:00)
|
83
|
+
74 6六金(75) (00:00/00:00:00)
|
84
|
+
75 6八飛(58) (00:00/00:00:00)
|
85
|
+
76 6五金(66) (00:00/00:00:00)
|
86
|
+
77 3二角打 (00:00/00:00:00)
|
87
|
+
78 8六歩(85) (00:00/00:00:00)
|
88
|
+
79 同歩(87) (00:00/00:00:00)
|
89
|
+
80 3五歩(34) (00:00/00:00:00)
|
90
|
+
81 2三角成(32) (00:00/00:00:00)
|
91
|
+
82 6四歩(63) (00:00/00:00:00)
|
92
|
+
83 3五歩(36) (00:00/00:00:00)
|
93
|
+
84 2一飛(61) (00:00/00:00:00)
|
94
|
+
85 3四馬(23) (00:00/00:00:00)
|
95
|
+
86 9二香(91) (00:00/00:00:00)
|
96
|
+
87 4八角(26) (00:00/00:00:00)
|
97
|
+
88 9一飛(21) (00:00/00:00:00)
|
98
|
+
89 2四歩(25) (00:00/00:00:00)
|
99
|
+
90 7五金(65) (00:00/00:00:00)
|
100
|
+
91 5六馬(34) (00:00/00:00:00)
|
101
|
+
92 8四歩打 (00:00/00:00:00)
|
102
|
+
93 7五角(48) (00:00/00:00:00)
|
103
|
+
94 同歩(74) (00:00/00:00:00)
|
104
|
+
95 6四飛(68) (00:00/00:00:00)
|
105
|
+
96 6三金(52) (00:00/00:00:00)
|
106
|
+
97 6八飛(64) (00:00/00:00:00)
|
107
|
+
98 6五角打 (00:00/00:00:00)
|
108
|
+
99 同飛(68) (00:00/00:00:00)
|
109
|
+
100 同桂(73) (00:00/00:00:00)
|
110
|
+
101 同馬(56) (00:00/00:00:00)
|
111
|
+
102 5九飛打 (00:00/00:00:00)
|
112
|
+
103 6六桂打 (00:00/00:00:00)
|
113
|
+
104 7三金(72) (00:00/00:00:00)
|
114
|
+
105 5二角打 (00:00/00:00:00)
|
115
|
+
106 6四金(63) (00:00/00:00:00)
|
116
|
+
107 同馬(65) (00:00/00:00:00)
|
117
|
+
108 同金(73) (00:00/00:00:00)
|
118
|
+
109 6五歩打 (00:00/00:00:00)
|
119
|
+
110 4八角打 (00:00/00:00:00)
|
120
|
+
111 6四歩(65) (00:00/00:00:00)
|
121
|
+
112 6六角成(48) (00:00/00:00:00)
|
122
|
+
113 7三金打 (00:00/00:00:00)
|
123
|
+
114 投了 (00:00/00:00:00)
|
@@ -0,0 +1 @@
|
|
1
|
+
position startpos moves 2g2f 3c3d 2f2e 2b3c 7g7f 3a4b 3i4h 5c5d 5i6h 5d5e 3g3f 8b5b 4h3g 4b5c 3g4f 5c4d 4i5h 5a6b 6h7h 6b7b 6g6f 7b8b 5h6g 7a7b 8h7g 9c9d 7h8h 9d9e 9i9h 8c8d 8h9i 7b8c 7i8h 6a7b 6f6e 7c7d 6g6f 8a7c 7g8f 5b5a 2h7h 8d8e 8f5i 3c4b 6i7i 2a3c 7f7e 7d7e 6f7e 4b7e 7h7e P*7d 7e7f G*7e 7f7h 5e5f 5g5f 7e6e 5f5e P*5f 5i2f 1c1d P*6b 4a5b 6b6a+ 5a6a 5e5d 6e6f 7h6h 6f7f P*7g 7f7e 6h5h 7e6f 5h6h 6f6e B*3b 8e8f 8g8f 3d3e 3b2c+ 6c6d 3f3e 6a2a 2c3d 9a9b 2f4h 2a9a 2e2d 6e7e 3d5f P*8d 4h7e 7d7e 6h6d 5b6c 6d6h B*6e 6h6e 7c6e 5f6e R*5i N*6f 7b7c B*5b 6c6d 6e6d 7c6d P*6e B*4h 6e6d 4h6f+ G*7c
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "../cli" if $0 == __FILE__
|
2
|
+
|
3
|
+
module Bioshogi
|
4
|
+
class CLI
|
5
|
+
desc "input_checker", "入力"
|
6
|
+
def input_checker(*argv)
|
7
|
+
InputParser.check(argv.join(" "))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
if $0 == __FILE__
|
13
|
+
Bioshogi::CLI.start(["input_checker", "68S", "△76歩 34歩"])
|
14
|
+
end
|
15
|
+
# >> |--------+--------------+-----------+----------+-----------+------------+----------------+-------------+--------------+---------------------+------------------+----------------+----------+----------+--------+-----------+-----------------+-------------------+---------+-----------+----------------------|
|
16
|
+
# >> | 入力 | ki2_location | kif_place | ki2_same | kif_piece | ki2_one_up | ki2_left_right | ki2_up_down | ki2_as_it_is | ki2_promote_trigger | kif_drop_trigger | kif_place_from | csa_sign | csa_from | csa_to | csa_piece | sfen_drop_piece | sfen_drop_trigger | sfen_to | sfen_from | sfen_promote_trigger |
|
17
|
+
# >> |--------+--------------+-----------+----------+-----------+------------+----------------+-------------+--------------+---------------------+------------------+----------------+----------+----------+--------+-----------+-----------------+-------------------+---------+-----------+----------------------|
|
18
|
+
# >> | 68S | | 68 | | S | | | | | | | | | | | | | | | | |
|
19
|
+
# >> | △76歩 | △ | 76 | | 歩 | | | | | | | | | | | | | | | | |
|
20
|
+
# >> | 34歩 | | 34 | | 歩 | | | | | | | | | | | | | | | | |
|
21
|
+
# >> |--------+--------------+-----------+----------+-----------+------------+----------------+-------------+--------------+---------------------+------------------+----------------+----------+----------+--------+-----------+-----------------+-------------------+---------+-----------+----------------------|
|
data/lib/bioshogi/cli/piece.rb
CHANGED
@@ -1,12 +1,7 @@
|
|
1
|
-
|
2
|
-
# bioshogi piece
|
3
|
-
|
4
|
-
if $0 == __FILE__
|
5
|
-
require "../cli"
|
6
|
-
end
|
1
|
+
require "../cli" if $0 == __FILE__
|
7
2
|
|
8
3
|
module Bioshogi
|
9
|
-
class
|
4
|
+
class CLI
|
10
5
|
desc "piece", "駒一覧"
|
11
6
|
def piece
|
12
7
|
tp Piece.collect(&:to_h)
|
@@ -15,5 +10,17 @@ module Bioshogi
|
|
15
10
|
end
|
16
11
|
|
17
12
|
if $0 == __FILE__
|
18
|
-
Bioshogi::
|
13
|
+
Bioshogi::CLI.start(["piece"])
|
19
14
|
end
|
15
|
+
# >> |--------+------+-------------+---------------+----------------------------+------------------------------+-----------+------------+--------------+----------+------|
|
16
|
+
# >> | key | name | basic_alias | promoted_name | promoted_formal_sheet_name | other_matched_promoted_names | sfen_char | promotable | always_alive | stronger | code |
|
17
|
+
# >> |--------+------+-------------+---------------+----------------------------+------------------------------+-----------+------------+--------------+----------+------|
|
18
|
+
# >> | king | 玉 | 王 | | | | K | false | true | false | 0 |
|
19
|
+
# >> | rook | 飛 | | 龍 | | 竜 | R | true | true | true | 1 |
|
20
|
+
# >> | bishop | 角 | | 馬 | | | B | true | true | true | 2 |
|
21
|
+
# >> | gold | 金 | | | | | G | false | true | false | 3 |
|
22
|
+
# >> | silver | 銀 | | 全 | 成銀 | | S | true | true | false | 4 |
|
23
|
+
# >> | knight | 桂 | | 圭 | 成桂 | 今 | N | true | false | false | 5 |
|
24
|
+
# >> | lance | 香 | | 杏 | 成香 | 仝 | L | true | false | false | 6 |
|
25
|
+
# >> | pawn | 歩 | | と | | | P | true | false | false | 7 |
|
26
|
+
# >> |--------+------+-------------+---------------+----------------------------+------------------------------+-----------+------------+--------------+----------+------|
|
data/lib/bioshogi/cli.rb
CHANGED
@@ -1,106 +1,20 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
#
|
3
|
-
# bioshogi versus -n 3
|
4
|
-
#
|
5
|
-
|
6
1
|
$LOAD_PATH.unshift(File.expand_path("..", __dir__))
|
7
2
|
|
8
3
|
require "bioshogi"
|
9
4
|
require "thor"
|
10
5
|
|
11
6
|
module Bioshogi
|
12
|
-
class
|
7
|
+
class CLI < Thor
|
13
8
|
class_option :debug, type: :boolean
|
14
9
|
class_option :quiet, type: :boolean
|
10
|
+
|
11
|
+
include Converter::CLI
|
12
|
+
include AI::Versus::CLI
|
15
13
|
end
|
16
|
-
end
|
17
14
|
|
18
|
-
Pathname(__dir__).glob("cli/*.rb").each
|
19
|
-
require file
|
15
|
+
Pathname(__dir__).glob("cli/*.rb").each { |e| require e }
|
20
16
|
end
|
21
17
|
|
22
18
|
if $0 == __FILE__
|
23
|
-
Bioshogi::
|
19
|
+
Bioshogi::CLI.start
|
24
20
|
end
|
25
|
-
# >> |------------------------|
|
26
|
-
# >> | Bioshogi::Diver::NegaAlphaDiver |
|
27
|
-
# >> | Bioshogi::Diver::NegaScoutDiver |
|
28
|
-
# >> |------------------------|
|
29
|
-
# >> {"depth_max"=>3,
|
30
|
-
# >> "times"=>1,
|
31
|
-
# >> "time_limit"=>3,
|
32
|
-
# >> "round"=>1,
|
33
|
-
# >> "logging"=>false,
|
34
|
-
# >> "log_file"=>"brain.log",
|
35
|
-
# >> "black_diver"=>"Diver::NegaAlphaDiver",
|
36
|
-
# >> "white_diver"=>"Diver::NegaScoutDiver"}
|
37
|
-
# >> |-------------+----------------|
|
38
|
-
# >> | depth_max | 3 |
|
39
|
-
# >> | times | 1 |
|
40
|
-
# >> | time_limit | 3 |
|
41
|
-
# >> | round | 1 |
|
42
|
-
# >> | logging | false |
|
43
|
-
# >> | log_file | brain.log |
|
44
|
-
# >> | black_diver | Diver::NegaAlphaDiver |
|
45
|
-
# >> | white_diver | Diver::NegaScoutDiver |
|
46
|
-
# >> |-------------+----------------|
|
47
|
-
# >> ---------------------------------------- [1] ▲7六歩(77) (Bioshogi::Diver::NegaAlphaDiver)
|
48
|
-
# >> |-----------------+------|
|
49
|
-
# >> | time_limit | 3 |
|
50
|
-
# >> | depth_max_range | 0..3 |
|
51
|
-
# >> |-----------------+------|
|
52
|
-
# >> |------+--------------+---------------------------+------+------------+----------|
|
53
|
-
# >> | 順位 | 候補手 | 読み筋 | 形勢 | 評価局面数 | 処理時間 |
|
54
|
-
# >> |------+--------------+---------------------------+------+------------+----------|
|
55
|
-
# >> | 1 | ▲7六歩(77) | △4四歩(43) ▲4四角(88) | 205 | 1050 | 0.129571 |
|
56
|
-
# >> | 2 | ▲9八香(99) | △1四歩(13) ▲4六歩(47) | 0 | 59 | 0.014618 |
|
57
|
-
# >> | 3 | ▲8六歩(87) | △1四歩(13) ▲6六歩(67) | 0 | 59 | 0.015365 |
|
58
|
-
# >> | 4 | ▲7八銀(79) | △1四歩(13) ▲1八香(19) | 0 | 57 | 0.0145 |
|
59
|
-
# >> | 5 | ▲6八銀(79) | △1四歩(13) ▲3八飛(28) | 0 | 56 | 0.012922 |
|
60
|
-
# >> | 6 | ▲6六歩(67) | △1四歩(13) ▲9六歩(97) | 0 | 59 | 0.015214 |
|
61
|
-
# >> | 7 | ▲7八金(69) | △1四歩(13) ▲5六歩(57) | 0 | 56 | 0.014731 |
|
62
|
-
# >> | 8 | ▲6八金(69) | △1四歩(13) ▲7六歩(77) | 0 | 56 | 0.014576 |
|
63
|
-
# >> | 9 | ▲5八金(69) | △1四歩(13) ▲2六歩(27) | 0 | 54 | 0.015056 |
|
64
|
-
# >> | 10 | ▲5六歩(57) | △1四歩(13) ▲4六歩(47) | 0 | 59 | 0.014406 |
|
65
|
-
# >> | 11 | ▲6八玉(59) | △1四歩(13) ▲7八銀(79) | 0 | 57 | 0.015313 |
|
66
|
-
# >> | 12 | ▲5八玉(59) | △1四歩(13) ▲1八香(19) | 0 | 56 | 0.014563 |
|
67
|
-
# >> | 13 | ▲4八玉(59) | △1四歩(13) ▲3八飛(28) | 0 | 55 | 0.015561 |
|
68
|
-
# >> | 14 | ▲4六歩(47) | △1四歩(13) ▲5八金(49) | 0 | 59 | 0.014996 |
|
69
|
-
# >> | 15 | ▲5八金(49) | △1四歩(13) ▲7八銀(79) | 0 | 54 | 0.015237 |
|
70
|
-
# >> | 16 | ▲4八金(49) | △1四歩(13) ▲9八香(99) | 0 | 54 | 0.014886 |
|
71
|
-
# >> | 17 | ▲3八金(49) | △1四歩(13) ▲1六歩(17) | 0 | 52 | 0.013963 |
|
72
|
-
# >> | 18 | ▲3六歩(37) | △1四歩(13) ▲3七桂(29) | 0 | 60 | 0.014453 |
|
73
|
-
# >> | 19 | ▲4八銀(39) | △1四歩(13) ▲4六歩(47) | 0 | 53 | 0.013778 |
|
74
|
-
# >> | 20 | ▲3八銀(39) | △1四歩(13) ▲9八香(99) | 0 | 52 | 0.01624 |
|
75
|
-
# >> | 21 | ▲2六歩(27) | △1四歩(13) ▲8六歩(87) | 0 | 60 | 0.015151 |
|
76
|
-
# >> | 22 | ▲3八飛(28) | △1四歩(13) ▲5八金(49) | 0 | 58 | 0.015105 |
|
77
|
-
# >> | 23 | ▲4八飛(28) | △1四歩(13) ▲9六歩(97) | 0 | 57 | 0.015086 |
|
78
|
-
# >> | 24 | ▲5八飛(28) | △1四歩(13) ▲5六歩(57) | 0 | 57 | 0.015008 |
|
79
|
-
# >> | 25 | ▲6八飛(28) | △1四歩(13) ▲7六歩(77) | 0 | 57 | 0.014952 |
|
80
|
-
# >> | 26 | ▲7八飛(28) | △1四歩(13) ▲5八金(49) | 0 | 58 | 0.014058 |
|
81
|
-
# >> | 27 | ▲1八飛(28) | △1四歩(13) ▲9六歩(97) | 0 | 59 | 0.016418 |
|
82
|
-
# >> | 28 | ▲1六歩(17) | △1四歩(13) ▲1七桂(29) | 0 | 61 | 0.014441 |
|
83
|
-
# >> | 29 | ▲9六歩(97) | △1四歩(13) ▲9七角(88) | 0 | 62 | 0.012523 |
|
84
|
-
# >> | 30 | ▲1八香(19) | △1四歩(13) ▲7六歩(77) | 0 | 57 | 0.015551 |
|
85
|
-
# >> |------+--------------+---------------------------+------+------------+----------|
|
86
|
-
# >> 後手の持駒:なし
|
87
|
-
# >> 9 8 7 6 5 4 3 2 1
|
88
|
-
# >> +---------------------------+
|
89
|
-
# >> |v香v桂v銀v金v玉v金v銀v桂v香|一
|
90
|
-
# >> | ・v飛 ・ ・ ・ ・ ・v角 ・|二
|
91
|
-
# >> |v歩v歩v歩v歩v歩v歩v歩v歩v歩|三
|
92
|
-
# >> | ・ ・ ・ ・ ・ ・ ・ ・ ・|四
|
93
|
-
# >> | ・ ・ ・ ・ ・ ・ ・ ・ ・|五
|
94
|
-
# >> | ・ ・ 歩 ・ ・ ・ ・ ・ ・|六
|
95
|
-
# >> | 歩 歩 ・ 歩 歩 歩 歩 歩 歩|七
|
96
|
-
# >> | ・ 角 ・ ・ ・ ・ ・ 飛 ・|八
|
97
|
-
# >> | 香 桂 銀 金 玉 金 銀 桂 香|九
|
98
|
-
# >> +---------------------------+
|
99
|
-
# >> 先手の持駒:なし
|
100
|
-
# >> 手数=1 ▲7六歩(77) まで
|
101
|
-
# >>
|
102
|
-
# >> 後手番
|
103
|
-
# >>
|
104
|
-
# >> ▲7六歩(77) 205
|
105
|
-
# >>
|
106
|
-
# >> ▲7六歩(77)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- compile-command: "../../.bin/bioshogi convert -f sfen assets/kifu_formats/sample.kif" -*-
|
2
|
+
|
3
|
+
module Bioshogi
|
4
|
+
class Converter
|
5
|
+
concern :CLI do
|
6
|
+
included do
|
7
|
+
desc "convert", "一括棋譜フォーマット変換"
|
8
|
+
option :format, type: :string, aliases: "-f", default: "kif"
|
9
|
+
option :output_dir, type: :string, aliases: "-o"
|
10
|
+
option :overwrite, type: :boolean, aliases: "-w", default: false
|
11
|
+
def convert(*files)
|
12
|
+
Converter.new(files, options.to_options).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(files, options = {})
|
18
|
+
@files = files
|
19
|
+
@options = {
|
20
|
+
:format => "kif",
|
21
|
+
:output_dir => nil,
|
22
|
+
:overwrite => false,
|
23
|
+
}.merge(options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def call
|
27
|
+
@files.each { |e| process_one(e) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_one(in_file)
|
31
|
+
in_file = Pathname(in_file).expand_path
|
32
|
+
info = Parser.file_parse(in_file)
|
33
|
+
str = info.public_send("to_#{@options[:format]}")
|
34
|
+
case
|
35
|
+
when @options[:overwrite]
|
36
|
+
in_file.write(str)
|
37
|
+
puts "[overwrite] #{in_file} => #{out_file}"
|
38
|
+
when @options[:output_dir].present?
|
39
|
+
out_file = output_dir + in_file.basename.sub_ext(extname)
|
40
|
+
FileUtils.mkdir_p(out_file.dirname)
|
41
|
+
out_file.write(str)
|
42
|
+
puts "[output] #{in_file} => #{out_file}"
|
43
|
+
else
|
44
|
+
puts str
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def output_dir
|
49
|
+
Pathname(@options[:output_dir]).expand_path
|
50
|
+
end
|
51
|
+
|
52
|
+
def extname
|
53
|
+
".#{@options[:format]}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -136,7 +136,7 @@ module Bioshogi
|
|
136
136
|
if error_list.exist?
|
137
137
|
files = error_list.readlines.reject { |e|e.match?("#") }.collect { |e| Pathname(e.strip) }
|
138
138
|
else
|
139
|
-
files =
|
139
|
+
files = ROOT.glob("../../2chkifu/**/*.{ki2,KI2}").sort # ~/src/2chkifu
|
140
140
|
end
|
141
141
|
files.take(limit)
|
142
142
|
end
|
@@ -4,6 +4,13 @@ module Bioshogi
|
|
4
4
|
module InputParser
|
5
5
|
extend self
|
6
6
|
|
7
|
+
def check(text)
|
8
|
+
rows = InputParser.scan(text).collect do |str|
|
9
|
+
{"入力" => str}.merge(match!(str).named_captures)
|
10
|
+
end
|
11
|
+
tp rows
|
12
|
+
end
|
13
|
+
|
7
14
|
def match!(str)
|
8
15
|
md = str.to_s.match(regexp)
|
9
16
|
unless md
|
data/lib/bioshogi/player.rb
CHANGED
data/lib/bioshogi/version.rb
CHANGED
data/lib/bioshogi.rb
CHANGED
@@ -9,6 +9,8 @@ require "active_support/core_ext/module/attribute_accessors" # for mattr_accesso
|
|
9
9
|
require "active_support/core_ext/string"
|
10
10
|
require "active_support/core_ext/array/grouping" # for in_groups_of
|
11
11
|
require "active_support/core_ext/numeric" # for 1.minute
|
12
|
+
require "active_support/core_ext/hash" # for too_options
|
13
|
+
require "active_support/core_ext/pathname" # for existence
|
12
14
|
|
13
15
|
require "pathname"
|
14
16
|
require "time" # for Time.parse
|
@@ -19,9 +21,10 @@ require "memory_record"
|
|
19
21
|
require "tree_support"
|
20
22
|
|
21
23
|
module Bioshogi
|
22
|
-
|
23
|
-
ASSETS_DIR =
|
24
|
-
LOG_DIR =
|
24
|
+
ROOT = Pathname(__dir__)
|
25
|
+
ASSETS_DIR = ROOT.join("bioshogi/assets")
|
26
|
+
LOG_DIR = ROOT.join("bioshogi/log")
|
27
|
+
TMP_DIR = ROOT.join("../tmp")
|
25
28
|
|
26
29
|
include ActiveSupport::Configurable
|
27
30
|
config_accessor(:skill_monitor_enable) { true }
|
@@ -30,33 +33,45 @@ module Bioshogi
|
|
30
33
|
SFEN1 = "position sfen l+n1g1g1n+l/1ks2r1+r1/1pppp1bpp/p2+b+sp+p2/9/P1P1+SP1PP/1+P+BPP1P2/1BK1GR1+R1/+L+NSG3NL b R2B3G4S5N11L99Pr2b3g4s5n11l99p 1"
|
31
34
|
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
loader.
|
36
|
-
|
37
|
-
|
38
|
-
loader.ignore("#{__dir__}/bioshogi/
|
39
|
-
loader.ignore("#{__dir__}/bioshogi/
|
40
|
-
loader.ignore("#{__dir__}/bioshogi/
|
41
|
-
loader.ignore("#{__dir__}/bioshogi/
|
42
|
-
loader.ignore("#{__dir__}/bioshogi/
|
43
|
-
|
44
|
-
#
|
45
|
-
loader.
|
46
|
-
|
47
|
-
|
48
|
-
loader.
|
49
|
-
loader.
|
50
|
-
|
51
|
-
|
52
|
-
loader.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
#
|
59
|
-
# loader.
|
60
|
-
|
61
|
-
|
62
|
-
|
36
|
+
if true
|
37
|
+
require "zeitwerk"
|
38
|
+
loader = Zeitwerk::Loader.for_gem
|
39
|
+
|
40
|
+
# 自動で読み込まないファイルやディレクトリを指定する
|
41
|
+
loader.ignore("#{__dir__}/bioshogi/logger.rb")
|
42
|
+
loader.ignore("#{__dir__}/bioshogi/vector_constants.rb")
|
43
|
+
loader.ignore("#{__dir__}/bioshogi/errors.rb")
|
44
|
+
loader.ignore("#{__dir__}/bioshogi/contrib/**/*.rb")
|
45
|
+
loader.ignore("#{__dir__}/bioshogi/assets")
|
46
|
+
loader.ignore("#{__dir__}/bioshogi/cli.rb")
|
47
|
+
loader.ignore("#{__dir__}/bioshogi/cli")
|
48
|
+
loader.ignore("#{__dir__}/bioshogi/explain/{備考,囲い,戦型,手筋}")
|
49
|
+
|
50
|
+
# 変換ルール調整
|
51
|
+
loader.inflector.inflect("cli" => "CLI")
|
52
|
+
loader.inflector.inflect("ai" => "AI")
|
53
|
+
|
54
|
+
# 開発環境専用のものは遅延読み込みする
|
55
|
+
loader.do_not_eager_load("#{__dir__}/bioshogi/explain/*_generator.rb")
|
56
|
+
loader.do_not_eager_load("#{__dir__}/bioshogi/explain/tactic_validator.rb")
|
57
|
+
loader.do_not_eager_load("#{__dir__}/bioshogi/explain/file_normalizer.rb")
|
58
|
+
loader.do_not_eager_load("#{__dir__}/bioshogi/extreme_validator.rb")
|
59
|
+
loader.do_not_eager_load("#{__dir__}/bioshogi/formatter/animation/demo_builder.rb")
|
60
|
+
|
61
|
+
# CLI用
|
62
|
+
# loader.do_not_eager_load("#{__dir__}/bioshogi/commands/*.rb")
|
63
|
+
|
64
|
+
loader.log! if false
|
65
|
+
|
66
|
+
loader.setup
|
67
|
+
|
68
|
+
require "bioshogi/logger"
|
69
|
+
require "bioshogi/vector_constants"
|
70
|
+
require "bioshogi/errors"
|
71
|
+
|
72
|
+
# 必須
|
73
|
+
# loader.eager_load_namespace(Bioshogi::ScreenImage)
|
74
|
+
|
75
|
+
# なくてもよい
|
76
|
+
loader.eager_load
|
77
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bioshogi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Ikeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -328,6 +328,7 @@ files:
|
|
328
328
|
- lib/bioshogi/ai/evaluator/level4.rb
|
329
329
|
- lib/bioshogi/ai/evaluator/opening_basic_table.rb
|
330
330
|
- lib/bioshogi/ai/player_brain_mod.rb
|
331
|
+
- lib/bioshogi/ai/versus.rb
|
331
332
|
- lib/bioshogi/application_memory_record.rb
|
332
333
|
- lib/bioshogi/assertion.rb
|
333
334
|
- lib/bioshogi/assets/audios/any.band/Alternatives/000/DisplayState.plist
|
@@ -604,6 +605,10 @@ files:
|
|
604
605
|
- lib/bioshogi/assets/images/piece/Portella/original/1RY.png
|
605
606
|
- lib/bioshogi/assets/images/piece/Portella/original/1TO.png
|
606
607
|
- lib/bioshogi/assets/images/piece/Portella/original/1UM.png
|
608
|
+
- lib/bioshogi/assets/kifu_formats/sample.csa
|
609
|
+
- lib/bioshogi/assets/kifu_formats/sample.ki2
|
610
|
+
- lib/bioshogi/assets/kifu_formats/sample.kif
|
611
|
+
- lib/bioshogi/assets/kifu_formats/sample.sfen
|
607
612
|
- lib/bioshogi/board.rb
|
608
613
|
- lib/bioshogi/board/basic.rb
|
609
614
|
- lib/bioshogi/board/csa_formatter.rb
|
@@ -621,10 +626,8 @@ files:
|
|
621
626
|
- lib/bioshogi/builder.rb
|
622
627
|
- lib/bioshogi/cli.rb
|
623
628
|
- lib/bioshogi/cli/.gitignore
|
624
|
-
- lib/bioshogi/cli/
|
625
|
-
- lib/bioshogi/cli/input_parser.rb
|
629
|
+
- lib/bioshogi/cli/input_checker.rb
|
626
630
|
- lib/bioshogi/cli/piece.rb
|
627
|
-
- lib/bioshogi/cli/versus.rb
|
628
631
|
- lib/bioshogi/container.rb
|
629
632
|
- lib/bioshogi/container/basic.rb
|
630
633
|
- lib/bioshogi/container/checkmate_yomiage.rb
|
@@ -635,6 +638,7 @@ files:
|
|
635
638
|
- lib/bioshogi/container/serialize_methods.rb
|
636
639
|
- lib/bioshogi/container/simple.rb
|
637
640
|
- lib/bioshogi/container/test_methods.rb
|
641
|
+
- lib/bioshogi/converter.rb
|
638
642
|
- lib/bioshogi/cover_image.rb
|
639
643
|
- lib/bioshogi/cover_image/bottom_text_methods.rb
|
640
644
|
- lib/bioshogi/cover_image/core_methods.rb
|
@@ -1142,7 +1146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1142
1146
|
- !ruby/object:Gem::Version
|
1143
1147
|
version: '0'
|
1144
1148
|
requirements: []
|
1145
|
-
rubygems_version: 3.4.
|
1149
|
+
rubygems_version: 3.4.22
|
1146
1150
|
signing_key:
|
1147
1151
|
specification_version: 4
|
1148
1152
|
summary: Shogi library
|
data/lib/bioshogi/cli/convert.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
# bioshogi convert -f ki2 ../../../experiment/katomomo.kif
|
3
|
-
|
4
|
-
if $0 == __FILE__
|
5
|
-
require "../cli"
|
6
|
-
end
|
7
|
-
|
8
|
-
module Bioshogi
|
9
|
-
class Cli
|
10
|
-
desc "convert", "一括棋譜フォーマット変換"
|
11
|
-
option :format, type: :string, aliases: "-f", default: "kif"
|
12
|
-
option :output_dir, type: :string, aliases: "-o", default: "output"
|
13
|
-
def convert(*files)
|
14
|
-
files.each do |in_file|
|
15
|
-
in_file = Pathname(in_file).expand_path
|
16
|
-
info = Parser.file_parse(in_file)
|
17
|
-
str = info.public_send("to_#{options[:format]}")
|
18
|
-
if options[:output_dir].blank?
|
19
|
-
puts str
|
20
|
-
else
|
21
|
-
dir = Pathname(options[:output_dir]).expand_path
|
22
|
-
out_file = dir.join(in_file.basename.sub_ext([".", options[:format]].join))
|
23
|
-
FileUtils.mkdir_p(dir)
|
24
|
-
out_file.write(str)
|
25
|
-
puts "#{in_file} => #{out_file}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
if $0 == __FILE__
|
33
|
-
Bioshogi::Cli.start(["convert", "-f", "ki2", "../../../experiment/katomomo.kif"])
|
34
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
# bioshogi input_parser "68歩" "△76歩"
|
3
|
-
|
4
|
-
if $0 == __FILE__
|
5
|
-
require "../cli"
|
6
|
-
end
|
7
|
-
|
8
|
-
module Bioshogi
|
9
|
-
class Cli
|
10
|
-
desc "input_parser", "入力"
|
11
|
-
def input_parser(*argv)
|
12
|
-
str = argv.join(" ")
|
13
|
-
rows = InputParser.scan(str).collect do |str|
|
14
|
-
{"入力" => str}.merge(InputParser.match!(str).named_captures)
|
15
|
-
end
|
16
|
-
tp rows
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
if $0 == __FILE__
|
22
|
-
Bioshogi::Cli.start(["input_parser", "68S", "△76歩"])
|
23
|
-
end
|