Module: Sashite::Pan

Defined in:
lib/sashite/pan.rb,
lib/sashite/pan/action.rb,
lib/sashite/pan/action/drop.rb,
lib/sashite/pan/action/move.rb,
lib/sashite/pan/action/pass.rb,
lib/sashite/pan/action/modify.rb,
lib/sashite/pan/action/capture.rb,
lib/sashite/pan/action/special.rb,
lib/sashite/pan/action/drop_capture.rb,
lib/sashite/pan/action/static_capture.rb

Overview

PAN (Portable Action Notation) implementation for Ruby

Provides functionality for working with atomic actions in abstract strategy board games using a human-readable string format with intuitive operator-based syntax.

This implementation is strictly compliant with PAN Specification v1.0.0

Defined Under Namespace

Modules: Action

Class Method Summary collapse

Class Method Details

.parse(pan_string) ⇒ Pan::Action

Parse a PAN string into an Action object

Examples:

Sashite::Pan.parse("e2-e4")      # => #<Pan::Action type=:move ...>
Sashite::Pan.parse("d1+f3")      # => #<Pan::Action type=:capture ...>
Sashite::Pan.parse("...")        # => #<Pan::Action type=:pass>
Sashite::Pan.parse("P*e5")       # => #<Pan::Action type=:drop ...>

Parameters:

  • pan_string (String)

    PAN notation string

Returns:

Raises:

  • (ArgumentError)

    if the PAN string is invalid



40
41
42
# File 'lib/sashite/pan.rb', line 40

def self.parse(pan_string)
  Action.parse(pan_string)
end

.valid?(pan_string) ⇒ Boolean

Check if a string represents a valid PAN action

Examples:

Sashite::Pan.valid?("e2-e4")     # => true
Sashite::Pan.valid?("d1+f3")     # => true
Sashite::Pan.valid?("...")       # => true
Sashite::Pan.valid?("P*e5")      # => true
Sashite::Pan.valid?("invalid")   # => false

Parameters:

  • pan_string (String)

    the string to validate

Returns:

  • (Boolean)

    true if the string is a valid PAN action



25
26
27
# File 'lib/sashite/pan.rb', line 25

def self.valid?(pan_string)
  Action.valid?(pan_string)
end