FEEN (Forsyth–Edwards Expanded Notation) support for the Ruby language.
This is an implementation of FEEN, a flexible and minimalist format for describing chess variant positions.
Add this line to your application's Gemfile:
gem "feen", ">= 5.0.0.beta1"
And then execute:
bundle install
Or install it yourself as:
gem install feen --pre
A position can be serialized by filling in these fields:
- Board shape: An array of integers. For instance, it would be
[10, 9]
for a Xiangqi board. Or it would be[8, 8]
for a Chess board. - Piece placement: Describes the placement of pieces on the board with a hash that references each piece on the board.
- Side to move: A char that indicates who moves next. In chess, "
w
" would mean that White can play a move.
From a classic Tsume Shogi problem:
require "feen"
Feen.dump(
board_shape: [9, 9],
side_to_move: "s",
piece_placement: {
3 => "s",
4 => "k",
5 => "s",
22 => "+P",
43 => "+B"
}
)
# => "3sks3/9/4+P4/9/7+B1/9/9/9/9 s"
Serialized positions can be converted back to fields.
require "feen"
Feen.parse("3sks3/9/4+P4/9/7+B1/9/9/9/9 s")
# {:board_shape=>[9, 9],
# :piece_placement=>{3=>"s", 4=>"k", 5=>"s", 22=>"+P", 43=>"+B"},
# :side_to_move=>"s"}
The code is available as open source under the terms of the MIT License.
This gem is maintained by Sashité.
With some lines of code, let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!