sashite-gan 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.md +1 -1
- data/README.md +30 -16
- data/lib/sashite-gan.rb +2 -0
- data/lib/sashite/gan.rb +35 -17
- metadata +68 -34
- data/.gitignore +0 -22
- data/.travis.yml +0 -3
- data/Gemfile +0 -2
- data/Rakefile +0 -7
- data/VERSION.semver +0 -1
- data/sashite-gan.gemspec +0 -19
- data/test/_test_helper.rb +0 -2
- data/test/test_gan.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: dffb3b5300bf9cfe17f98e0bea0fc2daa5a90d56df88a652e82f4a3b9056d7a1
|
4
|
+
data.tar.gz: a27352efa48e49bff0f89a1371853452edd6ffd09aca5cb8c1e360193f7576cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f635c1fd54f5a81b9c0303471011952197058a8997bcd006ce3f6776ad4ee845e04a444139ebba8c65b9f56b90f9225f305b17cc9b93d7bb1aa75fda8f50e2b
|
7
|
+
data.tar.gz: ac3c7237c234e7bd61c38edf7ac83acced6ef46951ffd19077b855a33f7ce5078edaced35be5b1ee7008fa26beff9102888c9935def92a45b75718210dcd5fac
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,6 @@
|
|
1
|
-
# Sashite::GAN
|
1
|
+
# Sashite::GAN ♟️
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
## Status
|
6
|
-
|
7
|
-
[![Gem Version](https://badge.fury.io/rb/sashite-gan.svg)](//badge.fury.io/rb/sashite-gan)
|
8
|
-
[![Build Status](https://secure.travis-ci.org/sashite/gan.rb.svg?branch=master)](//travis-ci.org/sashite/gan.rb?branch=master)
|
3
|
+
> An implementation of [General Actor Notation](https://developer.sashite.com/specs/general-actor-notation) for storing actors from abstract strategy games.
|
9
4
|
|
10
5
|
## Installation
|
11
6
|
|
@@ -25,14 +20,33 @@ Or install it yourself as:
|
|
25
20
|
|
26
21
|
require 'sashite-gan'
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
# Chess (Western) Rook, White
|
24
|
+
Sashite::GAN.string(is_checkmateable: false, is_promoted: false, is_topside: false, piece_abbr: 'r', style_abbr: 'c') # => 'C:R'
|
25
|
+
|
26
|
+
# Chess (Western) King, Black
|
27
|
+
Sashite::GAN.string(is_checkmateable: true, is_promoted: false, is_topside: true, piece_abbr: 'k', style_abbr: 'c') # => 'c:-k'
|
28
|
+
|
29
|
+
# Shogi King, Gote
|
30
|
+
Sashite::GAN.string(is_checkmateable: true, is_promoted: false, is_topside: true, piece_abbr: 'k', style_abbr: 's') # => 's:-k'
|
31
|
+
|
32
|
+
# Shogi promoted Pawn, Sente
|
33
|
+
Sashite::GAN.string(is_checkmateable: false, is_promoted: true, is_topside: false, piece_abbr: 'p', style_abbr: 's') # => 'S:+P'
|
34
|
+
|
35
|
+
# Xiangqi General, Red
|
36
|
+
Sashite::GAN.string(is_checkmateable: true, is_promoted: false, is_topside: false, piece_abbr: 'g', style_abbr: 'x') # => 'X:-G'
|
37
|
+
|
38
|
+
# Xiangqi Flying General, Red
|
39
|
+
Sashite::GAN.string(is_checkmateable: true, is_promoted: true, is_topside: false, piece_abbr: 'g', style_abbr: 'x') # => 'X:+-G'
|
40
|
+
|
41
|
+
# Go Stone, Black
|
42
|
+
Sashite::GAN.string(is_checkmateable: false, is_promoted: false, is_topside: false, piece_abbr: 's', style_abbr: 'go') # => 'GO:S'
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
47
|
+
|
48
|
+
## About Sashite
|
31
49
|
|
32
|
-
|
50
|
+
The `sashite-gan` gem is maintained by [Sashite](https://sashite.com/).
|
33
51
|
|
34
|
-
|
35
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
-
5. Create a new Pull Request
|
52
|
+
With some [lines of code](https://github.com/sashite/), let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!
|
data/lib/sashite-gan.rb
CHANGED
data/lib/sashite/gan.rb
CHANGED
@@ -1,25 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Sashite
|
2
|
-
|
3
|
-
|
4
|
-
|
4
|
+
# General Actor Notation
|
5
|
+
class GAN
|
6
|
+
# @return [String] The representation of an actor.
|
7
|
+
def self.string(is_checkmateable:, is_promoted:, is_topside:, piece_abbr:, style_abbr:)
|
8
|
+
unless [false, true].include?(is_topside)
|
9
|
+
raise TypeError, is_topside.class.inspect
|
10
|
+
end
|
11
|
+
|
12
|
+
piece_code = piece_code_builder(
|
13
|
+
piece_abbr: piece_abbr,
|
14
|
+
is_checkmateable: is_checkmateable,
|
15
|
+
is_promoted: is_promoted
|
16
|
+
)
|
17
|
+
|
18
|
+
piece_code_with_prefix = "#{style_abbr}:#{piece_code}"
|
5
19
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
20
|
+
if is_topside
|
21
|
+
piece_code_with_prefix.downcase
|
22
|
+
else
|
23
|
+
piece_code_with_prefix.upcase
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.piece_code_builder(piece_abbr:, is_checkmateable:, is_promoted:)
|
28
|
+
unless [false, true].include?(is_checkmateable)
|
29
|
+
raise TypeError, is_checkmateable.class.inspect
|
12
30
|
end
|
13
31
|
|
14
|
-
|
15
|
-
|
16
|
-
@dimension,
|
17
|
-
@cgh,
|
18
|
-
@side,
|
19
|
-
@variant,
|
20
|
-
@name
|
21
|
-
].join ':'
|
32
|
+
unless [false, true].include?(is_promoted)
|
33
|
+
raise TypeError, is_promoted.class.inspect
|
22
34
|
end
|
35
|
+
|
36
|
+
str = piece_abbr
|
37
|
+
str = "-#{str}" if is_checkmateable
|
38
|
+
str = "+#{str}" if is_promoted
|
39
|
+
str
|
23
40
|
end
|
41
|
+
private_class_method :piece_code_builder
|
24
42
|
end
|
25
43
|
end
|
metadata
CHANGED
@@ -1,81 +1,118 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sashite-gan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cyril
|
7
|
+
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rubocop-performance
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-thread_safety
|
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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
43
85
|
requirement: !ruby/object:Gem::Requirement
|
44
86
|
requirements:
|
45
|
-
- - "
|
87
|
+
- - ">="
|
46
88
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
89
|
+
version: '0'
|
48
90
|
type: :development
|
49
91
|
prerelease: false
|
50
92
|
version_requirements: !ruby/object:Gem::Requirement
|
51
93
|
requirements:
|
52
|
-
- - "
|
94
|
+
- - ">="
|
53
95
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
96
|
+
version: '0'
|
55
97
|
description: Implementation of GAN (General Actor Notation) for storing actors from
|
56
98
|
abstract strategy games.
|
57
|
-
email:
|
58
|
-
- contact@cyril.io
|
99
|
+
email: contact@cyril.email
|
59
100
|
executables: []
|
60
101
|
extensions: []
|
61
102
|
extra_rdoc_files: []
|
62
103
|
files:
|
63
|
-
- ".gitignore"
|
64
|
-
- ".travis.yml"
|
65
|
-
- Gemfile
|
66
104
|
- LICENSE.md
|
67
105
|
- README.md
|
68
|
-
- Rakefile
|
69
|
-
- VERSION.semver
|
70
106
|
- lib/sashite-gan.rb
|
71
107
|
- lib/sashite/gan.rb
|
72
|
-
|
73
|
-
- test/_test_helper.rb
|
74
|
-
- test/test_gan.rb
|
75
|
-
homepage: https://github.com/sashite/gan.rb
|
108
|
+
homepage: https://developer.sashite.com/specs/general-actor-notation
|
76
109
|
licenses:
|
77
110
|
- MIT
|
78
|
-
metadata:
|
111
|
+
metadata:
|
112
|
+
bug_tracker_uri: https://github.com/sashite/gan.rb/issues
|
113
|
+
documentation_uri: https://rubydoc.info/gems/sashite-gan/index
|
114
|
+
source_code_uri: https://github.com/sashite/gan.rb
|
115
|
+
wiki_uri: https://github.com/sashite/gan.rb/wiki
|
79
116
|
post_install_message:
|
80
117
|
rdoc_options: []
|
81
118
|
require_paths:
|
@@ -91,11 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
128
|
- !ruby/object:Gem::Version
|
92
129
|
version: '0'
|
93
130
|
requirements: []
|
94
|
-
|
95
|
-
rubygems_version: 2.2.2
|
131
|
+
rubygems_version: 3.1.2
|
96
132
|
signing_key:
|
97
133
|
specification_version: 4
|
98
134
|
summary: A GAN implementation in Ruby.
|
99
|
-
test_files:
|
100
|
-
- test/_test_helper.rb
|
101
|
-
- test/test_gan.rb
|
135
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
|
-
Gemfile.lock
|
7
|
-
InstalledFiles
|
8
|
-
_yardoc
|
9
|
-
coverage
|
10
|
-
doc/
|
11
|
-
lib/bundler/man
|
12
|
-
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/VERSION.semver
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.2
|
data/sashite-gan.gemspec
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |spec|
|
2
|
-
spec.name = 'sashite-gan'
|
3
|
-
spec.version = File.read('VERSION.semver')
|
4
|
-
spec.authors = ['Cyril Wack']
|
5
|
-
spec.email = ['contact@cyril.io']
|
6
|
-
spec.summary = %q{A GAN implementation in Ruby.}
|
7
|
-
spec.description = %q{Implementation of GAN (General Actor Notation) for storing actors from abstract strategy games.}
|
8
|
-
spec.homepage = 'https://github.com/sashite/gan.rb'
|
9
|
-
spec.license = 'MIT'
|
10
|
-
|
11
|
-
spec.files = `git ls-files -z`.split("\x0")
|
12
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
|
-
spec.test_files = spec.files.grep(%r{^test/})
|
14
|
-
spec.require_paths = ['lib']
|
15
|
-
|
16
|
-
spec.add_development_dependency 'bundler', '~> 1.6'
|
17
|
-
spec.add_development_dependency 'minitest', '~> 5'
|
18
|
-
spec.add_development_dependency 'rake', '~> 10'
|
19
|
-
end
|
data/test/_test_helper.rb
DELETED
data/test/test_gan.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require_relative '_test_helper'
|
2
|
-
|
3
|
-
describe Sashite::GAN::Actor do
|
4
|
-
describe '#to_s' do
|
5
|
-
before do
|
6
|
-
@actor = Sashite::GAN::Actor.new 2,
|
7
|
-
'bc096c4c7f48fc5c4c162555e4df98169e204aea',
|
8
|
-
'top', 'xianqi', 'rook'
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'returns the GAN of the actor' do
|
12
|
-
@actor.to_gan.must_equal '2:bc096c4c7f48fc5c4c162555e4df98169e204aea:top:xianqi:rook'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|