Module: Sashite::Feen
- Defined in:
- lib/sashite/feen.rb,
lib/sashite/feen/errors.rb,
lib/sashite/feen/parser.rb,
lib/sashite/feen/position.rb,
lib/sashite/feen/constants.rb,
lib/sashite/feen/parser/hands.rb,
lib/sashite/feen/position/hands.rb,
lib/sashite/feen/errors/argument.rb,
lib/sashite/feen/parser/style_turn.rb,
lib/sashite/feen/position/style_turn.rb,
lib/sashite/feen/parser/piece_placement.rb,
lib/sashite/feen/errors/argument/messages.rb,
lib/sashite/feen/position/piece_placement.rb
Overview
FEEN (Field Expression Encoding Notation) implementation for Ruby.
FEEN is a rule-agnostic format for encoding board game positions with three space-separated fields:
-
Piece Placement: Board occupancy
-
Hands: Off-board pieces held by each player
-
Style-Turn: Player styles and active player
Format
<PIECE-PLACEMENT> <HANDS> <STYLE-TURN>
Examples
# Parse a FEEN string
position = Sashite::Feen.parse("lnsgk^gsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGK^GSNL / S/s")
position.piece_placement # => PiecePlacement object
position.hands # => Hands object
position.style_turn # => StyleTurn object
# Serialize back to FEEN
position.to_s # => "lnsgk^gsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGK^GSNL / S/s"
# Validate a FEEN string
Sashite::Feen.valid?("lnsgk^gsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGK^GSNL / S/s") # => true
Sashite::Feen.valid?("invalid") # => false
Defined Under Namespace
Modules: Constants, Errors, Parser Classes: Position
Class Method Summary collapse
-
.parse(string) ⇒ Position
Parses a FEEN string into a Position.
-
.valid?(string) ⇒ Boolean
Checks if a string is a valid FEEN notation.