shogi-ruby 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/NEWS.ja.md +44 -0
- data/NEWS.md +20 -0
- data/README.md +2 -2
- data/lib/shogi/format/usi/board.rb +27 -0
- data/lib/shogi/game.rb +7 -0
- data/lib/shogi/version.rb +1 -1
- data/shogi-ruby.gemspec +1 -0
- data/test/test-board.rb +10 -10
- data/test/test-sfen.rb +29 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4320fa829ed79f026c8b76c8f5fd0e2ddcf3c97c
|
4
|
+
data.tar.gz: 3b76644ca595aa8959a7653a64ea2e2ff3f1e775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a741c74750a5cebfe61b59bf9c3c55e9b5767f5c839153671e16ddcf7dc1d42b064396d535b55f82cc6fefa6c42225be148804d0b18691a1a765dc7fece5b458
|
7
|
+
data.tar.gz: 7403f3f64862a3499b6ed7cc5dc20d0d9d22d5f650022b94cfa129c708db6a89ad069b5728fc61909685473a63b7d517cfa4e842239162eec599ed32e6759e28
|
data/.travis.yml
CHANGED
data/NEWS.ja.md
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
# お知らせ
|
2
2
|
|
3
|
+
## 0.1.0: 2017-08-31
|
4
|
+
|
5
|
+
### 変更点
|
6
|
+
|
7
|
+
* 改良
|
8
|
+
* SFEN(USI)形式の出力をサポートしました。[Shigeaki Matsumuraさんがパッチ提供]
|
9
|
+
* Added `Game#to_usi`.
|
10
|
+
* Added `Game#to_sfen` (the alias of `Game#to_usi`)
|
11
|
+
* Added `Board#to_usi`.
|
12
|
+
* Added `Board#to_sfen`. (the alias of `Board#to_usi`)
|
13
|
+
* Added `Board#usi_captured`.
|
14
|
+
* Added `Board#sfen_captured`. (the alias of `Board#usi_captured`)
|
15
|
+
* Ruby 2.0.0のサポートをやめました。
|
16
|
+
* TODO
|
17
|
+
* SFEN(USI)形式の入力(`Board#move_by_usi`)をサポートする
|
18
|
+
|
19
|
+
### Thanks
|
20
|
+
|
21
|
+
* Shigeaki Matsumuraさん
|
22
|
+
|
23
|
+
## 0.0.9: 2016-06-24
|
24
|
+
|
25
|
+
### Changes
|
26
|
+
|
27
|
+
* Improvements
|
28
|
+
* Improved mevement error detection. [Patch by Shigeaki Matsumura]
|
29
|
+
* Implemented Nifu restriction in `move_by_csa`. [Patch by Toru YAGI]
|
30
|
+
|
31
|
+
### Thanks
|
32
|
+
|
33
|
+
* Shigeaki Matsumura
|
34
|
+
* Toru YAGI
|
35
|
+
|
36
|
+
## 0.0.8: 2015-05-31
|
37
|
+
|
38
|
+
### Changes
|
39
|
+
|
40
|
+
* Improvements
|
41
|
+
* Supported Bundler.require (require "shogi-ruby").
|
42
|
+
* Added Board.register and Cell.register as plugin system.
|
43
|
+
* Removed a deprecated method `move_from_csa`.
|
44
|
+
* Fixes
|
45
|
+
* Fixed error messages.
|
46
|
+
|
3
47
|
## 0.0.7: 2013-10-29
|
4
48
|
|
5
49
|
### 変更点
|
data/NEWS.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# NEWS
|
2
2
|
|
3
|
+
## 0.1.0: 2017-08-31
|
4
|
+
|
5
|
+
### Changes
|
6
|
+
|
7
|
+
* Improvements
|
8
|
+
* Supported SFEN (USI) output. [Patch by Shigeaki Matsumura]
|
9
|
+
* Added `Game#to_usi`.
|
10
|
+
* Added `Game#to_sfen` (the alias of `Game#to_usi`)
|
11
|
+
* Added `Board#to_usi`.
|
12
|
+
* Added `Board#to_sfen`. (the alias of `Board#to_usi`)
|
13
|
+
* Added `Board#usi_captured`.
|
14
|
+
* Added `Board#sfen_captured`. (the alias of `Board#usi_captured`)
|
15
|
+
* Droped Ruby 2.0.0 support.
|
16
|
+
* TODO
|
17
|
+
* Support SFEN (USI) input (`Board#move_by_usi`).
|
18
|
+
|
19
|
+
### Thanks
|
20
|
+
|
21
|
+
* Shigeaki Matsumura
|
22
|
+
|
3
23
|
## 0.0.9: 2016-06-24
|
4
24
|
|
5
25
|
### Changes
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ Ruby用の将棋ライブラリです。
|
|
34
34
|
* 行きどころのない駒のチェック
|
35
35
|
* 詰みチェック
|
36
36
|
* 手番チェック
|
37
|
-
* USI
|
37
|
+
* USI形式との相互変換(盤面の出力のみ対応)
|
38
38
|
|
39
39
|
## Installation
|
40
40
|
|
@@ -52,7 +52,7 @@ Or install it yourself as:
|
|
52
52
|
|
53
53
|
## Ruby Version
|
54
54
|
|
55
|
-
Ruby 2.
|
55
|
+
Ruby 2.1 or later.
|
56
56
|
|
57
57
|
## Usage
|
58
58
|
|
@@ -29,6 +29,33 @@ module Shogi
|
|
29
29
|
usi_row
|
30
30
|
}.join("/") << "\n"
|
31
31
|
end
|
32
|
+
alias_method :to_sfen, :to_usi
|
33
|
+
|
34
|
+
def usi_captured
|
35
|
+
['+', '-'].map do |prefix|
|
36
|
+
caps = @captured
|
37
|
+
.select { |x| x[0] == prefix }
|
38
|
+
.map { |x| x[1..-1] }
|
39
|
+
.group_by { |x| x }
|
40
|
+
.map { |w, ws| [w, ws.length] }
|
41
|
+
.to_h
|
42
|
+
[Piece::HI,
|
43
|
+
Piece::KA,
|
44
|
+
Piece::KI,
|
45
|
+
Piece::GI,
|
46
|
+
Piece::KE,
|
47
|
+
Piece::KY,
|
48
|
+
Piece::FU].map do |type|
|
49
|
+
n = caps[type::CSA_NAME] || 0
|
50
|
+
usi = type::USI_NAME
|
51
|
+
usi = usi.downcase if prefix == '-'
|
52
|
+
"#{n}#{usi}" if n > 0
|
53
|
+
end.join
|
54
|
+
end.join.tap do |x|
|
55
|
+
return '-' if x == ''
|
56
|
+
end
|
57
|
+
end
|
58
|
+
alias_method :sfen_captured, :usi_captured
|
32
59
|
end
|
33
60
|
end
|
34
61
|
end
|
data/lib/shogi/game.rb
CHANGED
@@ -16,6 +16,13 @@ module Shogi
|
|
16
16
|
@board.to_csa << turn << "\n"
|
17
17
|
end
|
18
18
|
|
19
|
+
def to_usi
|
20
|
+
t = @turn == '+' ? 'b' : 'w'
|
21
|
+
next_num = @kifu.size + 1
|
22
|
+
@board.to_usi.chomp + " #{t} #{@board.usi_captured} #{next_num}"
|
23
|
+
end
|
24
|
+
alias_method :to_sfen, :to_usi
|
25
|
+
|
19
26
|
def move(movement_lines, format=@default_format)
|
20
27
|
movement_lines.each_line do |movement|
|
21
28
|
movement.chomp!
|
data/lib/shogi/version.rb
CHANGED
data/shogi-ruby.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency("test-unit")
|
22
22
|
spec.add_development_dependency("test-unit-notify")
|
23
23
|
spec.add_development_dependency("test-unit-rr")
|
24
|
+
spec.add_development_dependency("terminal-notifier")
|
24
25
|
spec.add_development_dependency("bundler")
|
25
26
|
spec.add_development_dependency("rake")
|
26
27
|
end
|
data/test/test-board.rb
CHANGED
@@ -133,28 +133,28 @@ lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL
|
|
133
133
|
@board.move("+2726AA")
|
134
134
|
end
|
135
135
|
assert_raise Shogi::MoveError do
|
136
|
-
|
136
|
+
@board.move("+2726HI")
|
137
137
|
end
|
138
138
|
assert_raise Shogi::MoveError do
|
139
|
-
|
139
|
+
@board.move("+2827HI")
|
140
140
|
end
|
141
141
|
assert_raise Shogi::MovementError do
|
142
|
-
|
142
|
+
@board.move("+2826HI")
|
143
143
|
end
|
144
144
|
assert_raise Shogi::MoveError do
|
145
|
-
|
145
|
+
@board.move("+2625FU")
|
146
146
|
end
|
147
147
|
assert_raise Shogi::MovementError do
|
148
|
-
|
148
|
+
@board.move("+2725FU")
|
149
149
|
end
|
150
150
|
assert_raise Shogi::MoveError do
|
151
|
-
|
151
|
+
@board.move("-4131KI")
|
152
152
|
end
|
153
153
|
assert_raise Shogi::MovementError do
|
154
|
-
|
154
|
+
@board.move("+8855KA")
|
155
155
|
end
|
156
156
|
assert_raise Shogi::MovementError do
|
157
|
-
|
157
|
+
@board.move("-1115KY")
|
158
158
|
end
|
159
159
|
|
160
160
|
assert_nothing_raised do
|
@@ -178,7 +178,7 @@ P-
|
|
178
178
|
EOT
|
179
179
|
|
180
180
|
assert_raise Shogi::MovementError do
|
181
|
-
|
181
|
+
@board.move("+8833UM").move("-2233KA").move("+0016FU")
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
@@ -243,7 +243,7 @@ P-00KA
|
|
243
243
|
@board.move("+7776FU", :csa)
|
244
244
|
@board.move("-3334FU", :csa)
|
245
245
|
assert_raise Shogi::MovementError do
|
246
|
-
|
246
|
+
@board.move("+2726TO", :csa)
|
247
247
|
end
|
248
248
|
assert_nothing_raised do
|
249
249
|
@board.move("+8822UM", :csa)
|
data/test/test-sfen.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'shogi/board'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
class SFENTest < Test::Unit::TestCase
|
5
|
+
def test_sfen_1
|
6
|
+
@game = Shogi::Game.new
|
7
|
+
assert_equal('lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1', @game.to_sfen)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_sfen_2
|
11
|
+
@game = Shogi::Game.new
|
12
|
+
@game.move('+7776FU', :csa)
|
13
|
+
@game.move('-3334FU', :csa)
|
14
|
+
@game.move('+2726FU', :csa)
|
15
|
+
@game.move('-8384FU', :csa)
|
16
|
+
@game.move('+2625FU', :csa)
|
17
|
+
@game.move('-8485FU', :csa)
|
18
|
+
@game.move('+6978KI', :csa)
|
19
|
+
@game.move('-4132KI', :csa)
|
20
|
+
@game.move('+2524FU', :csa)
|
21
|
+
@game.move('-2324FU', :csa)
|
22
|
+
@game.move('+2824HI', :csa)
|
23
|
+
@game.move('-8586FU', :csa)
|
24
|
+
@game.move('+8786FU', :csa)
|
25
|
+
@game.move('-8286HI', :csa)
|
26
|
+
@game.move('+2434HI', :csa)
|
27
|
+
assert_equal('lnsgk1snl/6gb1/p1pppp2p/6R2/9/1rP6/P2PPPP1P/1BG6/LNS1KGSNL w 3P2p 16', @game.to_sfen)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shogi-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: terminal-notifier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +128,7 @@ files:
|
|
114
128
|
- test/test-cell.rb
|
115
129
|
- test/test-game.rb
|
116
130
|
- test/test-piece.rb
|
131
|
+
- test/test-sfen.rb
|
117
132
|
homepage: https://github.com/myokoym/shogi-ruby
|
118
133
|
licenses:
|
119
134
|
- MIT
|
@@ -144,4 +159,4 @@ test_files:
|
|
144
159
|
- test/test-cell.rb
|
145
160
|
- test/test-game.rb
|
146
161
|
- test/test-piece.rb
|
147
|
-
|
162
|
+
- test/test-sfen.rb
|