feen.cr

FEEN support for the Crystal language.

FEEN.cr

Build Status

FEEN (Forsyth–Edwards Expanded Notation) support for the Crystal language.

Overview

This is an implementation of FEEN, a generic format that can be used for serializing and deserializing chess positions.

The main chess variants are supported, including Chess, Janggi, Makruk, Shogi, Xiangqi.

More exotic variants are also supported, like: Dai dai shogi, Four-player chess, or Three-dimensional chess 🖖

3D chess on Star Trek (from the episode "Court Martial")

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      feen:
        github: sashite/feen.cr
    
  2. Run shards install

Usage

require "feen"

# Dump a classic Tsume Shogi problem
FEEN.dump(
  "active_side_id": 0,
  "board": {
     3 => "s",
     4 => "k",
     5 => "s",
    22 => "+P",
    43 => "+B"
  },
  "indexes": [9, 9],
  "pieces_in_hand_grouped_by_sides": [
    %w[S],
    %w[r r b g g g g s n n n n p p p p p p p p p p p p p p p p p]
  ]
)
# => "3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s"

# Parse a classic Tsume Shogi problem
FEEN.parse("3,s,k,s,3/9/4,+P,4/9/7,+B,1/9/9/9/9 0 S/b,g,g,g,g,n,n,n,n,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,p,r,r,s")
# => {
#      "active_side_id": 0,
#      "board": {
#         3 => "s",
#         4 => "k",
#         5 => "s",
#        22 => "+P",
#        43 => "+B"
#      },
#      "indexes": [9, 9],
#      "pieces_in_hand_grouped_by_sides": [
#        %w[S],
#        %w[b g g g g n n n n p p p p p p p p p p p p p p p p p r r s]
#      ]
#    }

License

The code is available as open source under the terms of the MIT License.

About Sashite

This library is maintained by Sashite.

With some lines of code, let's share the beauty of Chinese, Japanese and Western cultures through the game of chess!

Owner
github statistic
  • 0
  • 0
  • 0
  • 0
  • 10 days ago
  • September 15, 2020
License

MIT License

Links
Synced at

Sun, 27 Sep 2020 04:31:27 GMT