qi 4.0.0 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: db34cbc61e929eb607b58f1682028288ad54d300
4
- data.tar.gz: 19997a2b81da2b4446068f94a3a641e4e9dc3e21
2
+ SHA256:
3
+ metadata.gz: 6d85f0a7a03ecc612c24bf29363b843fb88fa0572b8f74bf955eb92039314a54
4
+ data.tar.gz: ee40f146832333bf952ba810d1d95fafeabc8e6dc17905e39310b7c746faeb5f
5
5
  SHA512:
6
- metadata.gz: e7c53440130286c9518f74938bf5848bb5834d190eb7a7bcdedc2a098d3b96cb99e4832406ca1b3e81b57bee9614744259bf4b568f6f82cf16f3190482f56d5c
7
- data.tar.gz: ea38865a74444eb17142be9f4c9580da94ec2a07e1f7ef005c3c39f1158b3c00732b2b8def2b690a99746030e33268e6755683fba00abc3b051500ba2df61277
6
+ metadata.gz: 1310f61417a533fb3c6f19350b759f1831d1b9e7afc04ac4946ac36850cd53eea5ed27942af0f9132d93871047f888217f265d6db782e2d153453ec34c4c80fd
7
+ data.tar.gz: a2c2ca62646b82063b132d69a2f5fc15b062500a23daa6c5953154b23c798fdbbe9c4c6d4f3406be8b01b07c9737a0570c4d6fa0c27f69021c41a4fba79abb3d
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Cyril Wack
3
+ Copyright (c) 2015-2020 Sashite
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,23 +1,19 @@
1
- # Qi
1
+ # Qi.rb
2
2
 
3
- [![Build Status](https://travis-ci.org/cyril/qi.rb.svg?branch=master)][travis]
3
+ [![Build Status](https://travis-ci.org/sashite/qi.rb.svg?branch=master)](https://travis-ci.org/sashite/qi.rb)
4
4
  [![Gem Version](https://badge.fury.io/rb/qi.svg)][gem]
5
- [![Inline docs](http://inch-ci.org/github/cyril/qi.rb.svg?branch=master)][inchpages]
6
- [![Documentation](http://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
5
+ [![Inline docs](https://inch-ci.org/github/sashite/qi.rb.svg?branch=master)][inchpages]
6
+ [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
7
7
 
8
- > An ordered store of stuff to manage, for Ruby.
9
-
10
- ## Rubies
11
-
12
- * [MRI](https://www.ruby-lang.org/)
13
- * [Rubinius](http://rubini.us/)
14
- * [JRuby](http://jruby.org/)
8
+ > `Qi` (棋) is an abstraction for initializing and updating positions of chess variants (including Chess, Janggi, Markruk, Shogi, Xiangqi).
15
9
 
16
10
  ## Installation
17
11
 
18
12
  Add this line to your application's Gemfile:
19
13
 
20
- gem 'qi'
14
+ ```ruby
15
+ gem 'qi'
16
+ ```
21
17
 
22
18
  And then execute:
23
19
 
@@ -27,35 +23,142 @@ Or install it yourself as:
27
23
 
28
24
  $ gem install qi
29
25
 
30
- ## Example
26
+ ## Examples
27
+
28
+ Let's replay [The Shortest Possible Game of Shogi](https://userpages.monmouth.com/~colonel/shortshogi.html):
31
29
 
32
30
  ```ruby
33
31
  require 'qi'
34
32
 
35
- db = Qi::Store.new(8) # => #<Qi::Store:0x007f82129493c8 @cells=[nil, nil, nil, nil, nil, nil, nil, nil], @deleted_content=nil>
36
-
37
- result = db.call(2, 3, 'p') # => #<Qi::Store:0x007f821293a170 @cells=[nil, nil, nil, "p", nil, nil, nil, nil], @deleted_content=nil>
38
- result.store.cells # => [nil, nil, nil, "p", nil, nil, nil, nil]
39
- result.deleted_content # => nil
33
+ starting_position = Qi::Position.new(
34
+ 'l', 'n', 's', 'g', 'k', 'g', 's', 'n', 'l',
35
+ nil, 'r', nil, nil, nil, nil, nil, 'b', nil,
36
+ 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p',
37
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
38
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
39
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
40
+ 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P',
41
+ nil, 'B', nil, nil, nil, nil, nil, 'R', nil,
42
+ 'L', 'N', 'S', 'G', 'K', 'G', 'S', 'N', 'L'
43
+ )
44
+
45
+ starting_position.topside_in_hand_pieces # => []
46
+ starting_position.squares # => ["l", "n", "s", "g", "k", "g", "s", "n", "l",
47
+ # nil, "r", nil, nil, nil, nil, nil, "b", nil,
48
+ # "p", "p", "p", "p", "p", "p", "p", "p", "p",
49
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
50
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
51
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
52
+ # "P", "P", "P", "P", "P", "P", "P", "P", "P",
53
+ # nil, "B", nil, nil, nil, nil, nil, "R", nil,
54
+ # "L", "N", "S", "G", "K", "G", "S", "N", "L"]
55
+ starting_position.bottomside_in_hand_pieces # => []
56
+ starting_position.in_hand_pieces # => []
57
+ starting_position.turn_to_topside? # => false
58
+
59
+ # List of moves in Portable Move Notation (https://developer.sashite.com/specs/portable-move-notation) format.
60
+ moves = [
61
+ [ 56, 47, 'P' ],
62
+ [ 3, 11, 'g' ],
63
+ [ 64, 24, '+B', 'P' ],
64
+ [ 5, 14, 'g' ],
65
+ [ 24, 14, '+B', 'G' ],
66
+ [ 4, 3, 'k' ],
67
+ [ nil, 13, 'G' ]
68
+ ]
69
+
70
+ last_position = moves.reduce(starting_position) do |position, move|
71
+ position.call(move)
72
+ end
73
+
74
+ last_position.topside_in_hand_pieces # => []
75
+ last_position.squares # => ["l", "n", "s", "k", nil, nil, "s", "n", "l",
76
+ # nil, "r", "g", nil, "G", "+B", nil, "b", nil,
77
+ # "p", "p", "p", "p", "p", "p", nil, "p", "p",
78
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
79
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
80
+ # nil, nil, "P", nil, nil, nil, nil, nil, nil,
81
+ # "P", "P", nil, "P", "P", "P", "P", "P", "P",
82
+ # nil, nil, nil, nil, nil, nil, nil, "R", nil,
83
+ # "L", "N", "S", "G", "K", "G", "S", "N", "L"]
84
+ last_position.bottomside_in_hand_pieces # => ["P"]
85
+ last_position.in_hand_pieces # => []
86
+ last_position.turn_to_topside? # => true
40
87
  ```
41
88
 
42
- ## Versioning
43
-
44
- __Qi__ follows [Semantic Versioning 2.0](http://semver.org/).
89
+ Another example with Xiangqi's Short Double Cannons Checkmate:
45
90
 
46
- ## Contributing
91
+ ```ruby
92
+ require 'qi'
47
93
 
48
- 1. [Fork it](https://github.com/cyril/qi.rb/fork)
49
- 2. Create your feature branch (`git checkout -b my-new-feature`)
50
- 3. Commit your changes (`git commit -am 'Add some feature'`)
51
- 4. Push to the branch (`git push origin my-new-feature`)
52
- 5. Create a new Pull Request
94
+ starting_position = Qi::Position.new(
95
+ '車', '馬', '象', '士', '將', '士', '象', '馬', '車',
96
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
97
+ nil, '砲', nil, nil, nil, nil, nil, '砲', nil,
98
+ '卒', nil, '卒', nil, '卒', nil, '卒', nil, '卒',
99
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
100
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
101
+ '兵', nil, '兵', nil, '兵', nil, '兵', nil, '兵',
102
+ nil, '炮', nil, nil, nil, nil, nil, '炮', nil,
103
+ nil, nil, nil, nil, nil, nil, nil, nil, nil,
104
+ '俥', '傌', '相', '仕', '帥', '仕', '相', '傌', '俥'
105
+ )
106
+
107
+ starting_position.topside_in_hand_pieces # => []
108
+ starting_position.squares # => ["車", "馬", "象", "士", "將", "士", "象", "馬", "車",
109
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
110
+ # nil, "砲", nil, nil, nil, nil, nil, "砲", nil,
111
+ # "卒", nil, "卒", nil, "卒", nil, "卒", nil, "卒",
112
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
113
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
114
+ # "兵", nil, "兵", nil, "兵", nil, "兵", nil, "兵",
115
+ # nil, "炮", nil, nil, nil, nil, nil, "炮", nil,
116
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
117
+ # "俥", "傌", "相", "仕", "帥", "仕", "相", "傌", "俥"]
118
+ starting_position.bottomside_in_hand_pieces # => []
119
+ starting_position.in_hand_pieces # => []
120
+ starting_position.turn_to_topside? # => false
121
+
122
+ moves = [
123
+ [ 64, 67, '炮' ],
124
+ [ 25, 22, '砲' ],
125
+ [ 70, 52, '炮' ],
126
+ [ 19, 55, '砲' ],
127
+ [ 67, 31, '炮' ],
128
+ [ 22, 58, '砲' ],
129
+ [ 52, 49, '炮' ]
130
+ ]
131
+
132
+ last_position = moves.reduce(starting_position) do |position, move|
133
+ position.call(move)
134
+ end
135
+
136
+ last_position.topside_in_hand_pieces # => []
137
+ last_position.squares # => ["車", "馬", "象", "士", "將", "士", "象", "馬", "車",
138
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
139
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
140
+ # "卒", nil, "卒", nil, "炮", nil, "卒", nil, "卒",
141
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
142
+ # nil, nil, nil, nil, "炮", nil, nil, nil, nil,
143
+ # "兵", "砲", "兵", nil, "砲", nil, "兵", nil, "兵",
144
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
145
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
146
+ # "俥", "傌", "相", "仕", "帥", "仕", "相", "傌", "俥"]
147
+ last_position.bottomside_in_hand_pieces # => []
148
+ last_position.in_hand_pieces # => []
149
+ last_position.turn_to_topside? # => true
150
+ ```
53
151
 
54
152
  ## License
55
153
 
56
- See `LICENSE.md` file.
154
+ The code is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
155
+
156
+ ## About Sashite
157
+
158
+ This [gem](https://rubygems.org/gems/qi) is maintained by [Sashite](https://sashite.com/).
159
+
160
+ 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!
57
161
 
58
162
  [gem]: https://rubygems.org/gems/qi
59
- [travis]: https://travis-ci.org/cyril/qi.rb
60
- [inchpages]: http://inch-ci.org/github/cyril/qi.rb/
61
- [rubydoc]: http://rubydoc.info/gems/qi/frames
163
+ [inchpages]: https://inch-ci.org/github/sashite/qi.rb
164
+ [rubydoc]: https://rubydoc.info/gems/qi/frames
data/lib/qi.rb CHANGED
@@ -1,5 +1,7 @@
1
- # Namespace for the library.
1
+ # frozen_string_literal: true
2
+
3
+ # The Qi module.
2
4
  module Qi
3
5
  end
4
6
 
5
- require_relative File.join 'qi', 'store'
7
+ require_relative 'qi/position'
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Qi
4
+ # The position class.
5
+ #
6
+ # @see https://developer.sashite.com/specs/portable-chess-notation
7
+ class Position
8
+ # The list of squares of on the board.
9
+ #
10
+ # @!attribute [r] squares
11
+ # @return [Array] The list of squares.
12
+ attr_reader :squares
13
+
14
+ # The list of pieces in hand owned by the bottomside player.
15
+ #
16
+ # @!attribute [r] bottomside_in_hand_pieces
17
+ # @return [Array] The list of bottomside's pieces in hand.
18
+ attr_reader :bottomside_in_hand_pieces
19
+
20
+ # The list of pieces in hand owned by the topside player.
21
+ #
22
+ # @!attribute [r] topside_in_hand_pieces
23
+ # @return [Array] The list of topside's pieces in hand.
24
+ attr_reader :topside_in_hand_pieces
25
+
26
+ # Initialize a position.
27
+ #
28
+ # @param squares [Array] The list of squares of on the board.
29
+ # @param is_turn_to_topside [Boolean] The player who must play.
30
+ # @param bottomside_in_hand_pieces [Array] The list of bottom-side's pieces in hand.
31
+ # @param topside_in_hand_pieces [Array] The list of top-side's pieces in hand.
32
+ #
33
+ # @example Chess's starting position
34
+ # Position.new(
35
+ # '♜', '♞', '♝', '♛', '♚', '♝', '♞', '♜',
36
+ # '♟', '♟', '♟', '♟', '♟', '♟', '♟', '♟',
37
+ # nil, nil, nil, nil, nil, nil, nil, nil,
38
+ # nil, nil, nil, nil, nil, nil, nil, nil,
39
+ # nil, nil, nil, nil, nil, nil, nil, nil,
40
+ # nil, nil, nil, nil, nil, nil, nil, nil,
41
+ # '♙', '♙', '♙', '♙', '♙', '♙', '♙', '♙',
42
+ # '♖', '♘', '♗', '♕', '♔', '♗', '♘', '♖'
43
+ # )
44
+ #
45
+ # @example Makruk's starting position
46
+ # Position.new(
47
+ # '♜', '♞', '♝', '♛', '♚', '♝', '♞', '♜',
48
+ # nil, nil, nil, nil, nil, nil, nil, nil,
49
+ # '♟', '♟', '♟', '♟', '♟', '♟', '♟', '♟',
50
+ # nil, nil, nil, nil, nil, nil, nil, nil,
51
+ # nil, nil, nil, nil, nil, nil, nil, nil,
52
+ # '♙', '♙', '♙', '♙', '♙', '♙', '♙', '♙',
53
+ # nil, nil, nil, nil, nil, nil, nil, nil,
54
+ # '♖', '♘', '♗', '♔', '♕', '♗', '♘', '♖'
55
+ # )
56
+ #
57
+ # @example Shogi's starting position
58
+ # Position.new(
59
+ # 'l', 'n', 's', 'g', 'k', 'g', 's', 'n', 'l',
60
+ # nil, 'r', nil, nil, nil, nil, nil, 'b', nil,
61
+ # 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p',
62
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
63
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
64
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
65
+ # 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P', 'P',
66
+ # nil, 'B', nil, nil, nil, nil, nil, 'R', nil,
67
+ # 'L', 'N', 'S', 'G', 'K', 'G', 'S', 'N', 'L'
68
+ # )
69
+ #
70
+ # @example Xiangqi's starting position
71
+ # Position.new(
72
+ # '車', '馬', '象', '士', '將', '士', '象', '馬', '車',
73
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
74
+ # nil, '砲', nil, nil, nil, nil, nil, '砲', nil,
75
+ # '卒', nil, '卒', nil, '卒', nil, '卒', nil, '卒',
76
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
77
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
78
+ # '兵', nil, '兵', nil, '兵', nil, '兵', nil, '兵',
79
+ # nil, '炮', nil, nil, nil, nil, nil, '炮', nil,
80
+ # nil, nil, nil, nil, nil, nil, nil, nil, nil,
81
+ # '俥', '傌', '相', '仕', '帥', '仕', '相', '傌', '俥'
82
+ # )
83
+ def initialize(*squares, is_turn_to_topside: false, bottomside_in_hand_pieces: [], topside_in_hand_pieces: [])
84
+ @squares = squares
85
+ @is_turn_to_topside = is_turn_to_topside
86
+ @bottomside_in_hand_pieces = bottomside_in_hand_pieces
87
+ @topside_in_hand_pieces = topside_in_hand_pieces
88
+
89
+ freeze
90
+ end
91
+
92
+ # Apply a move in PMN (Portable Move Notation) format.
93
+ #
94
+ # @param move [Array] The move to play.
95
+ # @see https://developer.sashite.com/specs/portable-move-notation
96
+ # @return [Position] The new position.
97
+ def call(move)
98
+ updated_squares = squares.dup
99
+ updated_bottomside_in_hand_pieces = bottomside_in_hand_pieces.dup
100
+ updated_topside_in_hand_pieces = topside_in_hand_pieces.dup
101
+
102
+ actions = move.each_slice(4)
103
+
104
+ actions.each do |action|
105
+ src_square_id = action.fetch(0)
106
+ dst_square_id = action.fetch(1)
107
+ moved_piece_name = action.fetch(2)
108
+ captured_piece_name = action.fetch(3, nil)
109
+
110
+ if src_square_id.nil?
111
+ if turn_to_topside?
112
+ piece_in_hand_id = updated_topside_in_hand_pieces.index(moved_piece_name)
113
+ updated_topside_in_hand_pieces.delete_at(piece_in_hand_id)
114
+ else
115
+ piece_in_hand_id = updated_bottomside_in_hand_pieces.index(moved_piece_name)
116
+ updated_bottomside_in_hand_pieces.delete_at(piece_in_hand_id)
117
+ end
118
+ else
119
+ updated_squares[src_square_id] = nil
120
+ end
121
+
122
+ updated_squares[dst_square_id] = moved_piece_name
123
+
124
+ unless captured_piece_name.nil?
125
+ if turn_to_topside?
126
+ updated_topside_in_hand_pieces.push(captured_piece_name)
127
+ else
128
+ updated_bottomside_in_hand_pieces.push(captured_piece_name)
129
+ end
130
+ end
131
+ end
132
+
133
+ self.class.new(*updated_squares, is_turn_to_topside: !turn_to_topside?,
134
+ bottomside_in_hand_pieces: updated_bottomside_in_hand_pieces,
135
+ topside_in_hand_pieces: updated_topside_in_hand_pieces)
136
+ end
137
+
138
+ # The list of pieces in hand owned by the current player.
139
+ #
140
+ # @return [Array] Topside's pieces in hand if turn to topside, bottomside's
141
+ # ones otherwise.
142
+ def in_hand_pieces
143
+ turn_to_topside? ? topside_in_hand_pieces : bottomside_in_hand_pieces
144
+ end
145
+
146
+ # The side who must play.
147
+ #
148
+ # @return [Boolean] True if it is turn to topside, false otherwise.
149
+ def turn_to_topside?
150
+ @is_turn_to_topside
151
+ end
152
+ end
153
+ end
metadata CHANGED
@@ -1,130 +1,130 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qi
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 6.1.1
5
5
  platform: ruby
6
6
  authors:
7
- - Cyril Wack
7
+ - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-07 00:00:00.000000000 Z
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: brutal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - "~>"
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
- version: '1.10'
33
+ version: '0'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - "~>"
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: '1.10'
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - "~>"
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '10.4'
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - "~>"
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
- version: '10.4'
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: yard
56
+ name: rubocop-performance
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '0.8'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '0.8'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: simplecov
70
+ name: rubocop-thread_safety
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '0.10'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '0.10'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rubocop
84
+ name: simplecov
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: '0.34'
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: '0.34'
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: fix
98
+ name: yard
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '0.16'
103
+ version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '0.16'
97
- description: An ordered store of stuff to manage, for Ruby.
98
- email:
99
- - contact@cyril.email
110
+ version: '0'
111
+ description: Instantiate PCN's positions and apply PMN's moves.
112
+ email: contact@cyril.email
100
113
  executables: []
101
114
  extensions: []
102
115
  extra_rdoc_files: []
103
116
  files:
104
- - ".gitignore"
105
- - ".travis.yml"
106
- - ".yardopts"
107
- - CODE_OF_CONDUCT.md
108
- - Gemfile
109
117
  - LICENSE.md
110
118
  - README.md
111
- - Rakefile
112
- - VERSION.semver
113
- - bin/console
114
- - bin/setup
115
- - checksum/qi-3.0.0.gem.sha512
116
- - checksum/qi-3.0.1.gem.sha512
117
- - checksum/qi-3.0.2.gem.sha512
118
- - fix/store_fix.rb
119
- - fix/support/coverage.rb
120
119
  - lib/qi.rb
121
- - lib/qi/store.rb
122
- - pkg_checksum
123
- - qi.gemspec
124
- homepage: https://github.com/cyril/qi.rb
120
+ - lib/qi/position.rb
121
+ homepage: https://developer.sashite.com/specs/
125
122
  licenses:
126
123
  - MIT
127
- metadata: {}
124
+ metadata:
125
+ bug_tracker_uri: https://github.com/sashite/qi.rb/issues
126
+ documentation_uri: https://rubydoc.info/gems/qi/index
127
+ source_code_uri: https://github.com/sashite/qi.rb
128
128
  post_install_message:
129
129
  rdoc_options: []
130
130
  require_paths:
@@ -140,10 +140,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.4.5.1
143
+ rubygems_version: 3.1.2
145
144
  signing_key:
146
145
  specification_version: 4
147
- summary: Store to manage ordered stuff.
146
+ summary: Represent positions and play moves.
148
147
  test_files: []
149
- has_rdoc:
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.ruby-version
3
- /.yardoc
4
- /Gemfile.lock
5
- /_yardoc/
6
- /coverage/
7
- /doc/
8
- /pkg/
9
- /spec/reports/
10
- /tmp/
@@ -1,15 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- script: 'bundle exec rake test:coverage --trace'
5
- before_install:
6
- - gem install bundler
7
- rvm:
8
- - 1.9.3
9
- - 2.0
10
- - 2.1
11
- - 2.2
12
- - ruby-head
13
- - jruby
14
- - jruby-head
15
- - rbx-2
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- - README.md
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,21 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
- require 'rubocop/rake_task'
4
-
5
- RuboCop::RakeTask.new
6
-
7
- Rake::TestTask.new do |t|
8
- t.verbose = true
9
- t.warning = true
10
- t.pattern = File.join('fix', '**', '*_fix.rb')
11
- end
12
-
13
- namespace :test do
14
- task :coverage do
15
- ENV['COVERAGE'] = 'true'
16
- Rake::Task['test'].invoke
17
- end
18
- end
19
-
20
- task(:doc_stats) { ruby '-S yard stats' }
21
- task default: [:test, :doc_stats, :rubocop]
@@ -1 +0,0 @@
1
- 4.0.0
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'qi'
5
-
6
- require 'irb'
7
- IRB.start
data/bin/setup DELETED
@@ -1,5 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
@@ -1 +0,0 @@
1
- 7a4d1c15b8214a9eb475ed919ac4fcaf4b3a9aab5936b1522cbb801b243a649f95d23f42584c0fbad7f4a2ab71efaab9e6b030496a2f7471c74f74986e0e620d
@@ -1 +0,0 @@
1
- 03a1a4eb9f239b817fcab338c15c652a47183c0d58a63c505df1f6a7011ef0d9f2c94bb51f25c5ac455536b5f649dcbaa7087c6033ffe35c4acf5265efa0f853
@@ -1 +0,0 @@
1
- bacf809a9ee2de6656c3180bd7200503004cfd3017472501854a6e73cab84fc02f37c1190fabc15d3f1ff7cedbc1a0ff5bae2391f4766b2d27819a57c8713661
@@ -1,45 +0,0 @@
1
- require_relative File.join 'support', 'coverage'
2
- require_relative File.join '..', 'lib', 'qi'
3
- require 'fix'
4
-
5
- Fix.describe Qi::Store do
6
- on :new, 8 do
7
- on :cells do
8
- it { MUST eql [nil, nil, nil, nil, nil, nil, nil, nil] }
9
- end
10
-
11
- on :deleted_content do
12
- it { MUST be_nil }
13
- end
14
-
15
- on :call, 2, 3, 'p' do
16
- on :cells do
17
- it { MUST eql [nil, nil, nil, 'p', nil, nil, nil, nil] }
18
- end
19
-
20
- on :deleted_content do
21
- it { MUST be_nil }
22
- end
23
-
24
- on :call, 2, 4, 'K' do
25
- on :cells do
26
- it { MUST eql [nil, nil, nil, 'p', 'K', nil, nil, nil] }
27
- end
28
-
29
- on :deleted_content do
30
- it { MUST be_nil }
31
- end
32
-
33
- on :call, 3, 4, 'p' do
34
- on :cells do
35
- it { MUST eql [nil, nil, nil, nil, 'p', nil, nil, nil] }
36
- end
37
-
38
- on :deleted_content do
39
- it { MUST eql 'K' }
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,3 +0,0 @@
1
- require 'simplecov'
2
-
3
- SimpleCov.start
@@ -1,50 +0,0 @@
1
- module Qi
2
- # Main class.
3
- class Store
4
- # @example Instanciate a store with 88 cells.
5
- # new(88)
6
- #
7
- # @param size [Fixnum] The number of cell.
8
- # @param deleted_content [Object, nil] Deleted content.
9
- # @param options [Hash] A content per cell.
10
- def initialize(size, deleted_content = nil, options = {})
11
- @cells = Array.new(size)
12
- @deleted_content = deleted_content
13
-
14
- options.each do |cell, piece|
15
- @cells[cell] = piece
16
- end
17
- end
18
-
19
- # @!attribute [r] cells
20
- #
21
- # @return [Array] The cells in the store.
22
- attr_reader :cells
23
-
24
- # @!attribute [r] deleted_content
25
- #
26
- # @return [Object, nil] Deleted content.
27
- attr_reader :deleted_content
28
-
29
- # @param src_cell [Fixnum] Source cell.
30
- # @param dst_cell [Fixnum] Destination cell.
31
- # @param content [Object] Content.
32
- #
33
- # @return [Store] The new store.
34
- def call(src_cell, dst_cell, content)
35
- h = contents
36
- h.delete(src_cell)
37
- deleted_content = h.delete(dst_cell)
38
- h[dst_cell] = content
39
-
40
- self.class.new(cells.length, deleted_content, h)
41
- end
42
-
43
- private
44
-
45
- # @return [Hash] The contents in the store.
46
- def contents
47
- Hash[[*cells.map.with_index]].invert
48
- end
49
- end
50
- end
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'digest/sha2'
4
-
5
- gemname = :qi
6
- ARGV[0] = File.read('VERSION.semver').chomp if ARGV[0].nil?
7
- built_gem_path = "pkg/#{gemname}-#{ARGV[0]}.gem"
8
- checksum = Digest::SHA512.new.hexdigest(File.read(built_gem_path))
9
- checksum_path = "checksum/#{gemname}-#{ARGV[0]}.gem.sha512"
10
-
11
- File.open(checksum_path, 'w') { |f| f.write("#{checksum}\n") }
data/qi.gemspec DELETED
@@ -1,23 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = 'qi'
3
- spec.version = File.read('VERSION.semver').chomp
4
- spec.authors = ['Cyril Wack']
5
- spec.email = ['contact@cyril.email']
6
-
7
- spec.summary = 'Store to manage ordered stuff.'
8
- spec.description = 'An ordered store of stuff to manage, for Ruby.'
9
- spec.homepage = 'https://github.com/cyril/qi.rb'
10
- spec.license = 'MIT'
11
-
12
- spec.files =
13
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
14
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
15
- spec.require_paths = ['lib']
16
-
17
- spec.add_development_dependency 'bundler', '~> 1.10'
18
- spec.add_development_dependency 'rake', '~> 10.4'
19
- spec.add_development_dependency 'yard', '~> 0.8'
20
- spec.add_development_dependency 'simplecov', '~> 0.10'
21
- spec.add_development_dependency 'rubocop', '~> 0.34'
22
- spec.add_development_dependency 'fix', '~> 0.16'
23
- end