Module: Sashite::Pnn
- Defined in:
- lib/sashite/pnn.rb,
lib/sashite/pnn/piece.rb
Overview
PNN (Piece Name Notation) implementation for Ruby
Extends PIN to provide style-aware piece representation in abstract strategy board games. PNN adds a derivation marker that distinguishes pieces by their style origin, enabling cross-style game scenarios and piece origin tracking.
Format: <pin>
-
PIN component: [<state>]<letter> (state modifier + letter)
-
Suffix: “‘” for foreign style, none for native style
Examples:
"K" - First player king (native style)
"K'" - First player king (foreign style)
"+R" - First player rook, enhanced state (native style)
"+R'" - First player rook, enhanced state (foreign style)
"-p'" - Second player pawn, diminished state (foreign style)
Defined Under Namespace
Classes: Piece
Constant Summary collapse
- PNN_REGEX =
Regular expression for PNN validation Matches: optional state modifier, letter, optional derivation marker
/\A[-+]?[A-Za-z]'?\z/
Class Method Summary collapse
-
.parse(pnn_string) ⇒ Pnn::Piece
Parse a PNN string into a Piece object.
-
.valid?(pnn) ⇒ Boolean
Check if a string is a valid PNN notation.
Class Method Details
.parse(pnn_string) ⇒ Pnn::Piece
Parse a PNN string into a Piece object
56 57 58 |
# File 'lib/sashite/pnn.rb', line 56 def self.parse(pnn_string) Piece.parse(pnn_string) end |
.valid?(pnn) ⇒ Boolean
Check if a string is a valid PNN notation
41 42 43 44 45 |
# File 'lib/sashite/pnn.rb', line 41 def self.valid?(pnn) return false unless pnn.is_a?(::String) pnn.match?(PNN_REGEX) end |