0.0
No release in over 3 years
FEEN (Forsyth—Edwards Enhanced Notation) provides a universal, rule-agnostic format for representing board game positions. This gem implements the FEEN Specification v1.0.0 with a modern Ruby interface featuring immutable position objects and functional programming principles. FEEN extends traditional FEN notation to support multiple game systems (chess, shōgi, xiangqi, makruk), cross-style games, multi-dimensional boards, and captured pieces held in reserve. Built on EPIN (piece notation) and SIN (style notation) foundations, FEEN enables canonical position representation across diverse abstract strategy board games. Perfect for game engines, position analysis tools, and hybrid gaming systems requiring comprehensive board state representation.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

 Project Readme

Feen.rb

Version Yard documentation Ruby License

FEEN (Forsyth–Edwards Enhanced Notation) implementation for the Ruby language.

What is FEEN?

FEEN (Forsyth–Edwards Enhanced Notation) is a universal, rule-agnostic notation for representing board game positions. It extends traditional FEN to support multiple game systems, cross-style games, multi-dimensional boards, and captured pieces.

This gem implements the FEEN Specification v1.0.0 as a pure functional library with immutable data structures.

Installation

gem "sashite-feen"

API

The library provides two methods for converting between FEEN strings and position objects:

require "sashite/feen"

# Parse a FEEN string into a position object
position = Sashite::Feen.parse("+rnbq+kbn+r/+p+p+p+p+p+p+p+p/8/8/8/8/+P+P+P+P+P+P+P+P/+RNBQ+KBN+R / C/c")

# Dump a position object into a canonical FEEN string
feen_string = Sashite::Feen.dump(position)

Methods

Sashite::Feen.parse(string)

Parses a FEEN string and returns an immutable Position object.

  • Input: FEEN string with three space-separated fields
  • Returns: Sashite::Feen::Position instance
  • Raises: Sashite::Feen::Error subclasses on invalid input

Sashite::Feen.dump(position)

Converts a position object into its canonical FEEN string representation.

  • Input: Sashite::Feen::Position instance
  • Returns: Canonical FEEN string
  • Guarantees: Deterministic output (same position always produces same string)

Position Object

The Position object returned by parse is immutable and provides read-only access to the three FEEN components:

position.placement  # => Placement object (board arrangement)
position.hands      # => Hands object (pieces in hand)
position.styles     # => Styles object (style-turn information)
position.to_s       # => Canonical FEEN string (equivalent to dump)

Format

A FEEN string consists of three space-separated fields:

<piece-placement> <pieces-in-hand> <style-turn>
  1. Piece placement: Board configuration using EPIN notation
  2. Pieces in hand: Captured pieces held by each player
  3. Style-turn: Game styles and active player

For complete format details, see the FEEN Specification.

Error Handling

The library defines specific error classes for different validation failures:

Sashite::Feen::Error  # Base error class
├── Error::Syntax     # Malformed FEEN structure
├── Error::Piece      # Invalid EPIN notation
├── Error::Style      # Invalid SIN notation
├── Error::Count      # Invalid piece counts
└── Error::Validation # Other semantic violations

Properties

  • Purely functional: Immutable data structures, no side effects
  • Canonical output: Deterministic string generation
  • Specification compliant: Strict adherence to FEEN v1.0.0
  • Minimal API: Two methods for complete functionality
  • Composable: Built on EPIN and SIN specifications

Dependencies

Documentation

License

Available as open source under the MIT License.

About

Maintained by Sashité – promoting chess variants and sharing the beauty of board game cultures.