sashite-snn 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +104 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0f7d4b0f73aa8c0d12c8d7cdbcd910d667f6f87a2edf24ad2d97c177749d21
|
4
|
+
data.tar.gz: 13e22095a02f4b7f51d0b93d602974a2d6e3571db880524330e897f584d08e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e76c3b7058d5ae8cf82cde6a67f7690bc87017b127da8eae4c1389dc0d67924956bad2d4347119fa4e870f63a2e76d57910a1184f6e761b23bad53d80aad9b
|
7
|
+
data.tar.gz: 8b17d5c49b83f6408d5c99a28a5bf06929e6b1088daeea9b679b67eb24c8cd0dc8bf45db780ccda5497fb368fc9e8037b61003fa4c4d10d10797f41f4cde941d
|
data/README.md
CHANGED
@@ -9,9 +9,9 @@
|
|
9
9
|
|
10
10
|
## What is SNN?
|
11
11
|
|
12
|
-
SNN (Style Name Notation) is a
|
12
|
+
SNN (Style Name Notation) is a rule-agnostic format for identifying piece styles in abstract strategy board games, as defined in the [Game Protocol](https://sashite.dev/game-protocol/). It provides unambiguous identification of piece styles using standardized naming conventions with case-based player assignment, enabling clear distinction between different piece traditions in multi-style gaming environments.
|
13
13
|
|
14
|
-
This gem implements the [SNN Specification v1.0.0](https://sashite.dev/
|
14
|
+
This gem implements the [SNN Specification v1.0.0](https://sashite.dev/specs/snn/1.0.0/), providing a Ruby interface for working with style identifiers through a clean and minimal API.
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -28,18 +28,44 @@ gem install sashite-snn
|
|
28
28
|
|
29
29
|
## SNN Format
|
30
30
|
|
31
|
-
A SNN record consists of
|
31
|
+
A SNN record consists of a style identifier that maps to the **Style attribute** from the [Game Protocol](https://sashite.dev/game-protocol/):
|
32
32
|
|
33
33
|
```
|
34
|
-
<style-
|
34
|
+
<style-identifier>
|
35
35
|
```
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
-
|
37
|
+
### Grammar Specification
|
38
|
+
|
39
|
+
```bnf
|
40
|
+
<snn> ::= <uppercase-style> | <lowercase-style>
|
41
|
+
|
42
|
+
<uppercase-style> ::= <letter-uppercase> <identifier-tail-uppercase>*
|
43
|
+
<lowercase-style> ::= <letter-lowercase> <identifier-tail-lowercase>*
|
44
|
+
|
45
|
+
<identifier-tail-uppercase> ::= <letter-uppercase> | <digit>
|
46
|
+
<identifier-tail-lowercase> ::= <letter-lowercase> | <digit>
|
47
|
+
|
48
|
+
<letter-uppercase> ::= "A" | "B" | "C" | ... | "Z"
|
49
|
+
<letter-lowercase> ::= "a" | "b" | "c" | ... | "z"
|
50
|
+
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
|
51
|
+
```
|
52
|
+
|
53
|
+
### Protocol Mapping
|
54
|
+
|
55
|
+
SNN encodes style information with player association according to the Game Protocol:
|
56
|
+
|
57
|
+
| Protocol Attribute | SNN Encoding | Examples |
|
58
|
+
|-------------------|--------------|----------|
|
59
|
+
| **Style** | Alphanumeric identifier | `CHESS`, `SHOGI`, `XIANGQI` |
|
60
|
+
| **Player Association** | Case encoding | `CHESS` = First player, `chess` = Second player |
|
61
|
+
|
62
|
+
### Format Rules
|
63
|
+
|
64
|
+
- **Start character**: Must be alphabetic (`A-Z` for first player, `a-z` for second player)
|
65
|
+
- **Subsequent characters**: Alphabetic characters and digits only
|
66
|
+
- **Case consistency**: Entire identifier must be uppercase or lowercase (no mixed case)
|
67
|
+
- **Player assignment**: Uppercase = first player, lowercase = second player
|
68
|
+
- **Fixed assignment**: Player-style association remains constant throughout the match
|
43
69
|
|
44
70
|
## Basic Usage
|
45
71
|
|
@@ -91,16 +117,16 @@ end
|
|
91
117
|
|
92
118
|
### Player Association
|
93
119
|
|
94
|
-
Check which player a style belongs to:
|
120
|
+
Check which player a style belongs to according to the Game Protocol:
|
95
121
|
|
96
122
|
```ruby
|
97
123
|
first_player_style = Sashite::Snn::Style.parse("CHESS")
|
98
|
-
first_player_style.first_player? # => true
|
124
|
+
first_player_style.first_player? # => true (uppercase = first player)
|
99
125
|
first_player_style.second_player? # => false
|
100
126
|
|
101
127
|
second_player_style = Sashite::Snn::Style.parse("shogi")
|
102
128
|
second_player_style.first_player? # => false
|
103
|
-
second_player_style.second_player? # => true
|
129
|
+
second_player_style.second_player? # => true (lowercase = second player)
|
104
130
|
```
|
105
131
|
|
106
132
|
## Validation
|
@@ -109,21 +135,21 @@ All parsing automatically validates input according to the SNN specification:
|
|
109
135
|
|
110
136
|
```ruby
|
111
137
|
# Valid SNN strings
|
112
|
-
Sashite::Snn::Style.parse("CHESS") # ✓
|
113
|
-
Sashite::Snn::Style.parse("shogi") # ✓
|
114
|
-
Sashite::Snn::Style.parse("CHESS960") # ✓
|
115
|
-
Sashite::Snn::Style.parse("makruk") # ✓
|
138
|
+
Sashite::Snn::Style.parse("CHESS") # ✓ First player chess
|
139
|
+
Sashite::Snn::Style.parse("shogi") # ✓ Second player shogi
|
140
|
+
Sashite::Snn::Style.parse("CHESS960") # ✓ First player Chess960 variant
|
141
|
+
Sashite::Snn::Style.parse("makruk") # ✓ Second player makruk
|
116
142
|
|
117
143
|
# Valid constructor calls
|
118
|
-
Sashite::Snn::Style.new("XIANGQI") # ✓
|
119
|
-
Sashite::Snn::Style.new("janggi") # ✓
|
144
|
+
Sashite::Snn::Style.new("XIANGQI") # ✓ First player xiangqi
|
145
|
+
Sashite::Snn::Style.new("janggi") # ✓ Second player janggi
|
120
146
|
|
121
147
|
# Convenience method
|
122
|
-
Sashite::Snn.style("MINISHOGI") # ✓
|
148
|
+
Sashite::Snn.style("MINISHOGI") # ✓ First player minishogi
|
123
149
|
|
124
150
|
# Check validity
|
125
151
|
Sashite::Snn.valid?("CHESS") # => true
|
126
|
-
Sashite::Snn.valid?("Chess") # => false (mixed case)
|
152
|
+
Sashite::Snn.valid?("Chess") # => false (mixed case not allowed)
|
127
153
|
Sashite::Snn.valid?("123") # => false (must start with letter)
|
128
154
|
Sashite::Snn.valid?("") # => false (empty string)
|
129
155
|
|
@@ -139,9 +165,9 @@ Sashite::Snn::Style.parse("CHESS-960") # ✗ ArgumentError (contains hyphen)
|
|
139
165
|
### Classic Game Styles
|
140
166
|
|
141
167
|
```ruby
|
142
|
-
#
|
143
|
-
first_player = Sashite::Snn::Style.parse("CHESS") # First player
|
144
|
-
second_player = Sashite::Snn::Style.parse("chess") # Second player
|
168
|
+
# Traditional chess match (both players use chess pieces)
|
169
|
+
first_player = Sashite::Snn::Style.parse("CHESS") # First player
|
170
|
+
second_player = Sashite::Snn::Style.parse("chess") # Second player
|
145
171
|
|
146
172
|
# Cross-style game: Chess vs Shogi
|
147
173
|
first_player = Sashite::Snn::Style.parse("CHESS") # First player uses chess pieces
|
@@ -152,6 +178,31 @@ first_player = Sashite::Snn::Style.parse("CHESS960") # First player uses Chess96
|
|
152
178
|
second_player = Sashite::Snn::Style.parse("chess960") # Second player uses Chess960 variant
|
153
179
|
```
|
154
180
|
|
181
|
+
### Style Examples from SNN Specification
|
182
|
+
|
183
|
+
According to the [SNN Examples Documentation](https://sashite.dev/specs/snn/1.0.0/examples/):
|
184
|
+
|
185
|
+
| SNN | Interpretation |
|
186
|
+
|-----|----------------|
|
187
|
+
| `CHESS` | Chess first player (white) |
|
188
|
+
| `chess` | Chess second player (black) |
|
189
|
+
| `SHOGI` | Shōgi first player (sente) |
|
190
|
+
| `shogi` | Shōgi second player (gote) |
|
191
|
+
| `XIANGQI` | Xiangqi first player (red) |
|
192
|
+
| `xiangqi` | Xiangqi second player (black) |
|
193
|
+
|
194
|
+
```ruby
|
195
|
+
# Standard game representations
|
196
|
+
chess_white = Sashite::Snn::Style.parse("CHESS") # White pieces (first player)
|
197
|
+
chess_black = Sashite::Snn::Style.parse("chess") # Black pieces (second player)
|
198
|
+
|
199
|
+
shogi_sente = Sashite::Snn::Style.parse("SHOGI") # Sente (first player)
|
200
|
+
shogi_gote = Sashite::Snn::Style.parse("shogi") # Gote (second player)
|
201
|
+
|
202
|
+
xiangqi_red = Sashite::Snn::Style.parse("XIANGQI") # Red pieces (first player)
|
203
|
+
xiangqi_black = Sashite::Snn::Style.parse("xiangqi") # Black pieces (second player)
|
204
|
+
```
|
205
|
+
|
155
206
|
### Variant Styles
|
156
207
|
|
157
208
|
```ruby
|
@@ -210,31 +261,33 @@ style_configs = {
|
|
210
261
|
#### Player Queries
|
211
262
|
- `#first_player?` - Check if style belongs to first player (uppercase)
|
212
263
|
- `#second_player?` - Check if style belongs to second player (lowercase)
|
213
|
-
- `#uppercase?` -
|
214
|
-
- `#lowercase?` -
|
264
|
+
- `#uppercase?` - Check if identifier is uppercase
|
265
|
+
- `#lowercase?` - Check if identifier is lowercase
|
215
266
|
|
216
267
|
#### Conversion
|
217
268
|
- `#to_s` - Convert to SNN string representation
|
218
269
|
- `#to_sym` - Convert to symbol representation
|
219
270
|
- `#inspect` - Detailed string representation for debugging
|
220
271
|
|
221
|
-
## Properties
|
272
|
+
## Design Properties
|
273
|
+
|
274
|
+
Following the SNN specification, this implementation provides:
|
222
275
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
* **Fixed assignment**: Style assignment to players remains constant throughout a game
|
276
|
+
- **Rule-agnostic**: Independent of specific game mechanics
|
277
|
+
- **Unambiguous identification**: Clear distinction between different piece traditions
|
278
|
+
- **Cross-style support**: Enables multi-tradition gaming environments
|
279
|
+
- **Canonical representation**: Consistent naming for equivalent styles
|
280
|
+
- **Player clarity**: Case-based player association throughout gameplay
|
229
281
|
|
230
|
-
## Constraints
|
282
|
+
## System Constraints
|
231
283
|
|
232
284
|
* SNN supports exactly **two players**
|
233
285
|
* Players are distinguished by casing: **uppercase** for first player, **lowercase** for second player
|
234
286
|
* Style identifiers must start with an alphabetic character
|
235
|
-
* Subsequent characters may include alphabetic characters and digits
|
287
|
+
* Subsequent characters may include alphabetic characters and digits only
|
236
288
|
* Mixed casing is not permitted within a single identifier
|
237
289
|
* Style assignment to players remains **fixed throughout a game**
|
290
|
+
* Total piece count must remain constant (Game Protocol conservation principle)
|
238
291
|
|
239
292
|
## Use Cases
|
240
293
|
|
@@ -247,15 +300,27 @@ SNN is particularly useful in the following scenarios:
|
|
247
300
|
5. **Cross-tradition analysis**: When comparing or analyzing strategic elements across different piece traditions
|
248
301
|
6. **Tournament systems**: When organizing events that allow players to choose from different piece style traditions
|
249
302
|
|
303
|
+
## Game Protocol Compliance
|
304
|
+
|
305
|
+
This implementation fully complies with the [Game Protocol](https://sashite.dev/game-protocol/) by:
|
306
|
+
|
307
|
+
- Representing the **Style attribute** of pieces
|
308
|
+
- Supporting **two-player** constraint
|
309
|
+
- Maintaining **piece conservation** (styles are immutable)
|
310
|
+
- Enabling **cross-style** gameplay scenarios
|
311
|
+
- Providing **deterministic** style identification
|
312
|
+
|
250
313
|
## Documentation
|
251
314
|
|
252
|
-
- [Official SNN Specification](https://sashite.dev/
|
315
|
+
- [Official SNN Specification v1.0.0](https://sashite.dev/specs/snn/1.0.0/)
|
316
|
+
- [SNN Examples Documentation](https://sashite.dev/specs/snn/1.0.0/examples/)
|
317
|
+
- [Game Protocol Foundation](https://sashite.dev/game-protocol/)
|
253
318
|
- [API Documentation](https://rubydoc.info/github/sashite/snn.rb/main)
|
254
319
|
|
255
320
|
## License
|
256
321
|
|
257
|
-
|
322
|
+
Available as open source under the [MIT License](https://opensource.org/licenses/MIT).
|
258
323
|
|
259
|
-
## About
|
324
|
+
## About
|
260
325
|
|
261
|
-
|
326
|
+
Maintained by [Sashité](https://sashite.com/) — promoting chess variants and sharing the beauty of board game cultures.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sashite-snn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
@@ -50,7 +50,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
|
-
rubygems_version: 3.6.
|
53
|
+
rubygems_version: 3.6.9
|
54
54
|
specification_version: 4
|
55
55
|
summary: Style Name Notation (SNN) support for the Ruby language.
|
56
56
|
test_files: []
|