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
data/lib/bioshogi/cli/versus.rb
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
# frozen-string-literal: true
|
2
|
-
# bioshogi versus
|
3
|
-
|
4
|
-
if $0 == __FILE__
|
5
|
-
require "../cli"
|
6
|
-
end
|
7
|
-
|
8
|
-
module Bioshogi
|
9
|
-
class Cli < Thor
|
10
|
-
desc "versus", "CPU同士の対戦"
|
11
|
-
option :depth_max, type: :numeric, aliases: "-d", default: 8
|
12
|
-
option :times, type: :numeric, aliases: "-n", default: 512
|
13
|
-
option :time_limit, type: :numeric, aliases: "-t", default: 5.0
|
14
|
-
option :round, type: :numeric, aliases: "-r", default: 1
|
15
|
-
option :logging, type: :boolean, aliases: "-l", default: false
|
16
|
-
option :log_file, type: :string, default: "brain.log"
|
17
|
-
option :black_diver, type: :string, default: "Diver::NegaAlphaDiver"
|
18
|
-
option :white_diver, type: :string, default: "Diver::NegaScoutDiver"
|
19
|
-
def versus
|
20
|
-
if options[:logging]
|
21
|
-
log_file = Pathname(options[:log_file])
|
22
|
-
FileUtils.rm_rf(log_file)
|
23
|
-
Bioshogi.logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(log_file))
|
24
|
-
end
|
25
|
-
|
26
|
-
divers = [
|
27
|
-
Bioshogi::Ai.const_get(options[:black_diver]),
|
28
|
-
Bioshogi::Ai.const_get(options[:white_diver]),
|
29
|
-
]
|
30
|
-
tp divers
|
31
|
-
pp options
|
32
|
-
tp options
|
33
|
-
|
34
|
-
win_counts = Location.inject({}) { |a, e| a.merge(e.key => 0) }
|
35
|
-
|
36
|
-
options[:round].times do |round|
|
37
|
-
container = Container::Basic.start
|
38
|
-
options[:times].times do
|
39
|
-
current_player = container.current_player
|
40
|
-
|
41
|
-
deepen_score_list_params = {
|
42
|
-
time_limit: options[:time_limit],
|
43
|
-
depth_max_range: 0..options[:depth_max],
|
44
|
-
}
|
45
|
-
diver_class = divers[container.turn_info.current_location.code]
|
46
|
-
records = current_player.brain(diver_class: diver_class, evaluator_class: Ai::Evaluator::Level3).iterative_deepening(deepen_score_list_params)
|
47
|
-
record = records.first
|
48
|
-
hand = record[:hand]
|
49
|
-
container.execute(hand.to_sfen, executor_class: PlayerExecutor::WithoutMonitor)
|
50
|
-
|
51
|
-
puts "---------------------------------------- [#{container.turn_info.turn_offset}] #{hand} (#{diver_class})"
|
52
|
-
# container.players.each { |e| tp e.pressure_report }
|
53
|
-
|
54
|
-
tp deepen_score_list_params
|
55
|
-
tp Ai::Brain.human_format(records)
|
56
|
-
tp container.players.inject({}) { |a, e| a.merge(e.location => e.pressure_rate) }
|
57
|
-
puts container
|
58
|
-
puts
|
59
|
-
puts "#{hand} #{record[:black_side_score]}"
|
60
|
-
puts
|
61
|
-
puts container.to_kif_oneline
|
62
|
-
|
63
|
-
captured_soldier = current_player.executor.captured_soldier
|
64
|
-
if captured_soldier && captured_soldier.piece.key == :king
|
65
|
-
win_counts[current_player.location.key] += 1
|
66
|
-
Pathname("win_counts.txt").write(win_counts.inspect)
|
67
|
-
break
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
if $0 == __FILE__
|
76
|
-
Bioshogi::Cli.start(["versus", "-r1", "-n1", "-t3", "-d3"])
|
77
|
-
end
|
78
|
-
|
79
|
-
# >> |--------------------------|
|
80
|
-
# >> | Bioshogi::Diver::NegaAlphaDiver |
|
81
|
-
# >> | Bioshogi::Diver::NegaScoutDiver |
|
82
|
-
# >> |--------------------------|
|
83
|
-
# >> {"depth_max"=>3,
|
84
|
-
# >> "times"=>1,
|
85
|
-
# >> "time_limit"=>3,
|
86
|
-
# >> "round"=>1,
|
87
|
-
# >> "logging"=>false,
|
88
|
-
# >> "log_file"=>"brain.log",
|
89
|
-
# >> "black_diver"=>"Diver::NegaAlphaDiver",
|
90
|
-
# >> "white_diver"=>"Diver::NegaScoutDiver"}
|
91
|
-
# >> |-------------+----------------|
|
92
|
-
# >> | depth_max | 3 |
|
93
|
-
# >> | times | 1 |
|
94
|
-
# >> | time_limit | 3 |
|
95
|
-
# >> | round | 1 |
|
96
|
-
# >> | logging | false |
|
97
|
-
# >> | log_file | brain.log |
|
98
|
-
# >> | black_diver | Diver::NegaAlphaDiver |
|
99
|
-
# >> | white_diver | Diver::NegaScoutDiver |
|
100
|
-
# >> |-------------+----------------|
|
101
|
-
# >> ---------------------------------------- [1] ▲7六歩(77) (Bioshogi::Diver::NegaAlphaDiver)
|
102
|
-
# >> |-----------------+------|
|
103
|
-
# >> | time_limit | 3 |
|
104
|
-
# >> | depth_max_range | 0..3 |
|
105
|
-
# >> |-----------------+------|
|
106
|
-
# >> |------+--------------+--------------+--------+------------+----------|
|
107
|
-
# >> | 順位 | 候補手 | 読み筋 | ▲形勢 | 評価局面数 | 処理時間 |
|
108
|
-
# >> |------+--------------+--------------+--------+------------+----------|
|
109
|
-
# >> | 1 | ▲7六歩(77) | △3四歩(33) | 103400 | 30 | 0.031809 |
|
110
|
-
# >> | 2 | ▲2六歩(27) | △3四歩(33) | 103400 | 30 | 0.029595 |
|
111
|
-
# >> | 3 | ▲1六歩(17) | △3四歩(33) | 103394 | 30 | 0.028082 |
|
112
|
-
# >> | 4 | ▲9六歩(97) | △3四歩(33) | 103394 | 30 | 0.029372 |
|
113
|
-
# >> | 5 | ▲3六歩(37) | △3四歩(33) | 103394 | 30 | 0.030666 |
|
114
|
-
# >> | 6 | ▲4六歩(47) | △3四歩(33) | 103393 | 30 | 0.029278 |
|
115
|
-
# >> | 7 | ▲6六歩(67) | △3四歩(33) | 103393 | 30 | 0.029187 |
|
116
|
-
# >> | 8 | ▲4八玉(59) | △3四歩(33) | 103392 | 30 | 0.02889 |
|
117
|
-
# >> | 9 | ▲4八銀(39) | △3四歩(33) | 103392 | 30 | 0.027835 |
|
118
|
-
# >> | 10 | ▲6八銀(79) | △3四歩(33) | 103392 | 30 | 0.029386 |
|
119
|
-
# >> | 11 | ▲7八銀(79) | △3四歩(33) | 103392 | 30 | 0.029047 |
|
120
|
-
# >> | 12 | ▲3八銀(39) | △3四歩(33) | 103392 | 30 | 0.029677 |
|
121
|
-
# >> | 13 | ▲6八玉(59) | △3四歩(33) | 103392 | 30 | 0.027244 |
|
122
|
-
# >> | 14 | ▲5八玉(59) | △3四歩(33) | 103392 | 30 | 0.029223 |
|
123
|
-
# >> | 15 | ▲7八金(69) | △3四歩(33) | 103391 | 30 | 0.027379 |
|
124
|
-
# >> | 16 | ▲5八金(49) | △3四歩(33) | 103391 | 30 | 0.029436 |
|
125
|
-
# >> | 17 | ▲6八金(69) | △3四歩(33) | 103391 | 30 | 0.028743 |
|
126
|
-
# >> | 18 | ▲5八金(69) | △3四歩(33) | 103391 | 30 | 0.028421 |
|
127
|
-
# >> | 19 | ▲4八金(49) | △3四歩(33) | 103391 | 30 | 0.02853 |
|
128
|
-
# >> | 20 | ▲3八金(49) | △3四歩(33) | 103391 | 30 | 0.026771 |
|
129
|
-
# >> | 21 | ▲3八飛(28) | △3四歩(33) | 103391 | 30 | 0.03523 |
|
130
|
-
# >> | 22 | ▲4八飛(28) | △3四歩(33) | 103391 | 30 | 0.036152 |
|
131
|
-
# >> | 23 | ▲5八飛(28) | △3四歩(33) | 103391 | 30 | 0.034372 |
|
132
|
-
# >> | 24 | ▲6八飛(28) | △3四歩(33) | 103391 | 30 | 0.027788 |
|
133
|
-
# >> | 25 | ▲7八飛(28) | △3四歩(33) | 103391 | 30 | 0.029031 |
|
134
|
-
# >> | 26 | ▲5六歩(57) | △3四歩(33) | 103390 | 30 | 0.029354 |
|
135
|
-
# >> | 27 | ▲8六歩(87) | △3四歩(33) | 103390 | 30 | 0.030806 |
|
136
|
-
# >> | 28 | ▲9八香(99) | △3四歩(33) | 103390 | 30 | 0.029306 |
|
137
|
-
# >> | 29 | ▲1八香(19) | △3四歩(33) | 103390 | 30 | 0.027871 |
|
138
|
-
# >> | 30 | ▲1八飛(28) | △3四歩(33) | 103390 | 30 | 0.040798 |
|
139
|
-
# >> |------+--------------+--------------+--------+------------+----------|
|
140
|
-
# >> 後手の持駒:なし
|
141
|
-
# >> 9 8 7 6 5 4 3 2 1
|
142
|
-
# >> +---------------------------+
|
143
|
-
# >> |v香v桂v銀v金v玉v金v銀v桂v香|一
|
144
|
-
# >> | ・v飛 ・ ・ ・ ・ ・v角 ・|二
|
145
|
-
# >> |v歩v歩v歩v歩v歩v歩v歩v歩v歩|三
|
146
|
-
# >> | ・ ・ ・ ・ ・ ・ ・ ・ ・|四
|
147
|
-
# >> | ・ ・ ・ ・ ・ ・ ・ ・ ・|五
|
148
|
-
# >> | ・ ・ 歩 ・ ・ ・ ・ ・ ・|六
|
149
|
-
# >> | 歩 歩 ・ 歩 歩 歩 歩 歩 歩|七
|
150
|
-
# >> | ・ 角 ・ ・ ・ ・ ・ 飛 ・|八
|
151
|
-
# >> | 香 桂 銀 金 玉 金 銀 桂 香|九
|
152
|
-
# >> +---------------------------+
|
153
|
-
# >> 先手の持駒:なし
|
154
|
-
# >> 手数=1 ▲7六歩(77) まで
|
155
|
-
# >>
|
156
|
-
# >> 後手番
|
157
|
-
# >>
|
158
|
-
# >> ▲7六歩(77) 103400
|
159
|
-
# >>
|
160
|
-
# >> ▲7六歩(77)
|