#file-format #chess-board #player #com #piece #writer #parser

fen4

A parser and writer for the fen4 file format used by Chess.com for 4 player chess games

7 releases (breaking)

0.7.0 May 16, 2021
0.6.0 Apr 10, 2021
0.5.0 Feb 26, 2021
0.4.0 Dec 28, 2020
0.1.0 Oct 10, 2020

#1581 in Parser implementations


Used in pgn4

MIT license

43KB
997 lines

fen4

A Rust library to parse and write fen4 file formats.

This provides a mapping from a simple representation of a 4 player chess board and the fen4 file format used by Chess.com. Any non-trivial computation is likely to have a separate data format, but this generates useful error messages and correctly handles almost every variation of 4 player chess (including tons of non-standard pieces).

Usage

Cargo.toml

[dependencies]
fen4 = "0.7"
fn main(){
    let empty_fen = "R-0,0,0,0-0,0,0,0-0,0,0,0-0,0,0,0-0-14/14/14/14/14/14/14/14/14/14/14/14/14/14";
    let board : Result<fen4::Board,fen4::BoardParseError> = empty_fen.parse();
    println!("{}",board.unwrap());
}

Rust version requirements

fen4 requires rustc version 1.45 or greater. This is for str.strip_prefix; working arount this requirement would move support needed back to around 1.32.


lib.rs:

Fen4 provides a mapping from a simple representation of a 4 player chess board and the fen4 file format used by Chess.com.

Quick Start

The Board struct is the important type in this crate. All other types are present to support all the features of Board. The most common ways to get a Board would be via FromStr or Default.

let empty_fen = "R-0,0,0,0-0,0,0,0-0,0,0,0-0,0,0,0-0-14/14/14/14/14/14/14/14/14/14/14/14/14/14";
let board :  Result<fen4::Board,fen4::BoardParseError> = empty_fen.parse();
println!("{}",board?);

Dependencies

~285–750KB
~18K SLoC