0.0
No release in over 3 years
SNN (Style Name Notation) provides a rule-agnostic, scalable naming system for identifying abstract strategy board game styles. This gem implements the SNN Specification v1.0.0 with a modern Ruby interface featuring immutable style name objects and functional programming principles. SNN uses canonical ASCII names (e.g., "Shogi", "Go9x9") to unambiguously refer to game styles across variants and traditions. Ideal for engines, protocols, and tools that need clear and extensible style identifiers.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Snn.rb

Version Yard documentation Ruby License

SNN (Style Name Notation) implementation for the Ruby language.

What is SNN?

SNN (Style Name Notation) is a formal, rule-agnostic naming system for identifying styles in abstract strategy board games such as chess, shōgi, xiangqi, and their many variants. Each style is represented by a canonical, human-readable ASCII name (e.g., "Chess", "Shogi", "Xiangqi", "Minishogi").

This gem implements the SNN Specification v1.0.0, supporting validation, parsing, and comparison of style names.

Installation

# In your Gemfile
gem "sashite-snn"

Or install manually:

gem install sashite-snn

Usage

Basic Operations

require "sashite/snn"

# Parse SNN strings into style name objects
name = Sashite::Snn.parse("Shogi")             # => #<Snn::Name value="Shogi">
name.to_s                                      # => "Shogi"
name.value                                     # => "Shogi"

# Create from string or symbol
name = Sashite::Snn.name("Chess")              # => #<Snn::Name value="Chess">
name = Sashite::Snn::Name.new(:Xiangqi)        # => #<Snn::Name value="Xiangqi">

# Validate SNN strings
Sashite::Snn.valid?("Go9x9")                   # => true
Sashite::Snn.valid?("chess")                   # => false (must start with uppercase)
Sashite::Snn.valid?("3DChess")                 # => false (invalid character)

Normalization and Comparison

a = Sashite::Snn.parse("Chess960")
b = Sashite::Snn.parse("Chess960")

a == b                                         # => true
a.same_base_name?(Sashite::Snn.parse("Chess")) # => true if both resolve to same SIN
a.to_s # => "Chess960"

Canonical Representation

# All names are normalized to a canonical format
name = Sashite::Snn.parse("Minishogi")
name.value                                    # => "Minishogi"
name.to_s                                     # => "Minishogi"

Collections and Filtering

names = %w[Chess Shogi Makruk Antichess Minishogi].map { |n| Sashite::Snn.parse(n) }

# Filter by prefix
names.select { |n| n.value.start_with?("Mini") }.map(&:to_s)
# => ["Minishogi"]

Format Specification

Structure

<uppercase-letter>[<lowercase-letter | digit>]*

Grammar (BNF)

<snn> ::= <uppercase-letter> <tail>

<tail> ::= ""                                ; Single letter (e.g., "X")
        | <alphanumeric-char> <tail>         ; Extended name

<alphanumeric-char> ::= <lowercase-letter> | <digit>

<uppercase-letter> ::= "A" | "B" | "C" | ... | "Z"
<lowercase-letter> ::= "a" | "b" | "c" | ... | "z"
<digit> ::= "0" | "1" | "2" | "3" | ... | "9"

Regular Expression

/\A[A-Z][a-z0-9]*\z/

Design Principles

  • Human-readable: Names like "Shogi" or "Chess960" are intuitive and descriptive.
  • Canonical: One valid name per game style within a given context.
  • ASCII-only: Compatible with all systems.
  • Scalable: Supports unlimited distinct names for current and future game variants.

Integration with SIN

SNN names serve as the formal source for SIN character identifiers. For example:

SNN SIN
Chess C/c
Shogi S/s
Xiangqi X/x
Makruk M/m

Multiple SNN names may map to the same SIN character (e.g., "Chess" and "Chess960" both → C), but SNN provides unambiguous naming within broader contexts.

Examples

Sashite::Snn.parse("Chess")       # => #<Snn::Name value="Chess">
Sashite::Snn.parse("Chess960")    # => #<Snn::Name value="Chess960">
Sashite::Snn.valid?("Minishogi")  # => true
Sashite::Snn.valid?("miniShogi")  # => false

API Reference

Main Module

  • Sashite::Snn.valid?(str) – Returns true if the string is valid SNN.
  • Sashite::Snn.parse(str) – Returns a Sashite::Snn::Name object.
  • Sashite::Snn.name(sym_or_str) – Alias for constructing a name.

Sashite::Snn::Name

  • #value – Returns the canonical string value.
  • #to_s – Returns the string representation.
  • #==, #eql?, #hash – Value-based equality.
  • #same_base_name?(other) – Optional helper for SIN mapping equivalence.

Development

# Clone the repository
git clone https://github.com/sashite/snn.rb.git
cd snn.rb

# Install dependencies
bundle install

# Run tests
ruby test.rb

# Generate documentation
yard doc

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/new-feature)
  3. Add tests for your changes
  4. Ensure all tests pass (ruby test.rb)
  5. Commit your changes (git commit -am 'Add new feature')
  6. Push to the branch (git push origin feature/new-feature)
  7. Create a Pull Request

License

Available as open source under the MIT License.

About

Maintained by Sashité — promoting chess variants and sharing the beauty of board game cultures.