Module: Sashite::Cgsn
- Defined in:
- lib/sashite/cgsn.rb
Overview
CGSN (Chess Game Status Notation) implementation for Ruby.
Provides a rule-agnostic vocabulary for identifying game statuses in abstract strategy board games with symbol-based identifiers.
Constant Summary collapse
- INFERABLE_STATUSES =
Position-inferable status symbols.
These can be determined from Position + Rule System alone.
Set[ :check, :stale, :checkmate, :stalemate, :nomove, :bareking, :mareking, :insufficient ].freeze
- EXPLICIT_ONLY_STATUSES =
Explicit-only status symbols.
These require external context (history, clocks, declarations).
Set[ :resignation, :illegalmove, :timelimit, :movelimit, :repetition, :agreement ].freeze
- STATUSES =
All CGSN v1.0.0 status symbols.
(INFERABLE_STATUSES | EXPLICIT_ONLY_STATUSES).freeze
Class Method Summary collapse
-
.explicit_only?(status) ⇒ Boolean
Reports whether the status is explicit-only.
-
.explicit_only_statuses ⇒ Set<Symbol>
Returns explicit-only status symbols.
-
.inferable?(status) ⇒ Boolean
Reports whether the status is position-inferable.
-
.inferable_statuses ⇒ Set<Symbol>
Returns position-inferable status symbols.
-
.parse(input) ⇒ Symbol
Parses a CGSN string into a symbol.
-
.statuses ⇒ Set<Symbol>
Returns all CGSN v1.0.0 status symbols.
-
.valid?(input) ⇒ Boolean
Reports whether the input is a valid CGSN status string.
Class Method Details
.explicit_only?(status) ⇒ Boolean
Reports whether the status is explicit-only.
Explicit-only statuses require external context (history, clocks, declarations) and cannot be derived from Position + Rule System alone.
129 130 131 132 133 |
# File 'lib/sashite/cgsn.rb', line 129 def self.explicit_only?(status) return false unless ::Symbol === status EXPLICIT_ONLY_STATUSES.include?(status) end |
.explicit_only_statuses ⇒ Set<Symbol>
Returns explicit-only status symbols.
164 165 166 |
# File 'lib/sashite/cgsn.rb', line 164 def self.explicit_only_statuses EXPLICIT_ONLY_STATUSES end |
.inferable?(status) ⇒ Boolean
Reports whether the status is position-inferable.
Position-inferable statuses can be determined from Position + Rule System without external context (history, clocks, declarations).
111 112 113 114 115 |
# File 'lib/sashite/cgsn.rb', line 111 def self.inferable?(status) return false unless ::Symbol === status INFERABLE_STATUSES.include?(status) end |
.inferable_statuses ⇒ Set<Symbol>
Returns position-inferable status symbols.
153 154 155 |
# File 'lib/sashite/cgsn.rb', line 153 def self.inferable_statuses INFERABLE_STATUSES end |
.parse(input) ⇒ Symbol
Parses a CGSN string into a symbol.
76 77 78 79 80 |
# File 'lib/sashite/cgsn.rb', line 76 def self.parse(input) raise ::ArgumentError, "invalid status" unless valid?(input) :"#{input}" end |
.statuses ⇒ Set<Symbol>
Returns all CGSN v1.0.0 status symbols.
142 143 144 |
# File 'lib/sashite/cgsn.rb', line 142 def self.statuses STATUSES end |
.valid?(input) ⇒ Boolean
Reports whether the input is a valid CGSN status string.
93 94 95 96 97 |
# File 'lib/sashite/cgsn.rb', line 93 def self.valid?(input) return false unless ::String === input VALID_STRINGS.include?(input) end |