CGSN (Chess Game Status Notation) implementation for the Ruby language.
CGSN (Chess Game Status Notation) provides a rule-agnostic taxonomy of observable game status values for abstract strategy board games. CGSN defines standardized identifiers for terminal conditions, player actions, and game progression states that can be recorded independently of competitive interpretation.
This gem implements the CGSN Specification v1.0.0, providing a minimal Ruby interface for status validation and categorization with immutable status objects.
# In your Gemfile
gem "sashite-cgsn"Or install manually:
gem install sashite-cgsnCGSN status values are lowercase strings using underscore separators:
"checkmate"
"bare_king"
"time_limit"
"in_progress"Sashite::Cgsn::Status.new(value)- Create status instance from stringSashite::Cgsn.parse(value)- Parse status value (module convenience method)
#inferable?- Check if status can be inferred from position analysis#explicit_only?- Check if status requires explicit declaration#to_s- Convert to string representation#==(other)- Equality comparison#hash- Hash value for use in collections
Sashite::Cgsn.valid?(status)- Check if string is a valid CGSN status value
Sashite::Cgsn.inferable?(status)- Check if status can be inferred from position analysisSashite::Cgsn.explicit_only?(status)- Check if status requires explicit declaration
Sashite::Cgsn.statuses- Array of all defined CGSN status valuesSashite::Cgsn.inferable_statuses- Array of position-derivable statusesSashite::Cgsn.explicit_only_statuses- Array of statuses requiring explicit recording
Sashite::Cgsn::STATUSES- Frozen array of all defined status valuesSashite::Cgsn::INFERABLE_STATUSES- Frozen array of inferable status valuesSashite::Cgsn::EXPLICIT_ONLY_STATUSES- Frozen array of explicit-only status values
require "sashite/cgsn"
# Parse status into object
status = Sashite::Cgsn.parse("checkmate")
status.inferable? # => true
status.explicit_only? # => false
status.to_s # => "checkmate"
# Create from string
status = Sashite::Cgsn::Status.new("resignation")
status.inferable? # => false
status.explicit_only? # => true
# Immutable objects
status.frozen? # => truerequire "sashite/cgsn"
# Validate status strings
Sashite::Cgsn.valid?("checkmate") # => true
Sashite::Cgsn.valid?("invalid") # => false
# Check inference capability
Sashite::Cgsn.inferable?("stalemate") # => true
Sashite::Cgsn.explicit_only?("time_limit") # => true
# Get all statuses
Sashite::Cgsn.statuses
# => ["in_progress", "checkmate", "stalemate", ...]- Rule-agnostic: Independent of specific game mechanics or outcome interpretation
- Observable-focused: Records verifiable facts without competitive judgment
- Inference-aware: Distinguishes position-derivable from explicit-only statuses
- String-based: Simple string representation for broad compatibility
- Functional: Pure functions with no side effects
- Immutable: All status instances and data structures are frozen
- Object-oriented: Status objects with query methods
- CGSN - Chess Game Status Notation (this specification)
- PCN - Portable Chess Notation (uses CGSN for status field)
- Game Protocol - Conceptual foundation for abstract strategy games
# Clone the repository
git clone https://github.com/sashite/cgsn.rb.git
cd cgsn.rb
# Install dependencies
bundle install
# Run tests
ruby test.rb
# Generate documentation
yard doc- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Add tests for your changes
- Ensure all tests pass (
ruby test.rb) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
Available as open source under the MIT License.
Maintained by Sashité — promoting chess variants and sharing the beauty of board game cultures.