Module: Sashite::Epin

Defined in:
lib/sashite/epin.rb,
lib/sashite/epin/identifier.rb

Overview

EPIN (Extended Piece Identifier Notation) implementation for Ruby

Provides style-aware ASCII-based format for representing pieces in abstract strategy board games. EPIN extends PIN by adding derivation markers that distinguish pieces by their style origin, enabling cross-style game scenarios and piece origin tracking.

Format: [<state>]<letter>

  • State modifier: “+” (enhanced), “-” (diminished), or none (normal)

  • Letter: A-Z (first player), a-z (second player)

  • Derivation marker: “‘” (foreign style), or none (native style)

Examples:

"K"   - First player king (native style, normal state)
"k'"  - Second player king (foreign style, normal state)
"+R'" - First player rook (foreign style, enhanced state)
"-p"  - Second player pawn (native style, diminished state)

Defined Under Namespace

Classes: Identifier

Class Method Summary collapse

Class Method Details

.identifier(type, side, state, native) ⇒ Epin::Identifier

Create a new identifier instance

Examples:

Sashite::Epin.identifier(:K, :first, :normal, true)      # => #<Epin::Identifier type=:K side=:first state=:normal native=true>
Sashite::Epin.identifier(:R, :first, :enhanced, false)   # => #<Epin::Identifier type=:R side=:first state=:enhanced native=false>
Sashite::Epin.identifier(:P, :second, :diminished, true) # => #<Epin::Identifier type=:P side=:second state=:diminished native=true>

Parameters:

  • type (Symbol)

    piece type (:A to :Z)

  • side (Symbol)

    player side (:first or :second)

  • state (Symbol)

    piece state (:normal, :enhanced, or :diminished)

  • native (Boolean)

    style derivation (true for native, false for foreign)

Returns:

Raises:

  • (ArgumentError)

    if parameters are invalid



65
66
67
# File 'lib/sashite/epin.rb', line 65

def self.identifier(type, side, state, native)
  Identifier.new(type, side, state, native)
end

.parse(epin_string) ⇒ Epin::Identifier

Parse an EPIN string into an Identifier object

Examples:

Sashite::Epin.parse("K")     # => #<Epin::Identifier type=:K side=:first state=:normal native=true>
Sashite::Epin.parse("+R'")   # => #<Epin::Identifier type=:R side=:first state=:enhanced native=false>
Sashite::Epin.parse("-p")    # => #<Epin::Identifier type=:P side=:second state=:diminished native=true>

Parameters:

  • epin_string (String)

    EPIN notation string

Returns:

Raises:

  • (ArgumentError)

    if the EPIN string is invalid



49
50
51
# File 'lib/sashite/epin.rb', line 49

def self.parse(epin_string)
  Identifier.parse(epin_string)
end

.valid?(epin_string) ⇒ Boolean

Check if a string is a valid EPIN notation

Examples:

Sashite::Epin.valid?("K")     # => true
Sashite::Epin.valid?("+R'")   # => true
Sashite::Epin.valid?("-p")    # => true
Sashite::Epin.valid?("KK")    # => false
Sashite::Epin.valid?("++K")   # => false

Parameters:

  • epin_string (String)

    The string to validate

Returns:

  • (Boolean)

    true if valid EPIN, false otherwise



36
37
38
# File 'lib/sashite/epin.rb', line 36

def self.valid?(epin_string)
  Identifier.valid?(epin_string)
end