#shogi #move #usi #sfen

shogi

Bitboard based Shogi library. Board representation, move handlings and various time control utilities.

14 releases (breaking)

0.11.0 Oct 4, 2021
0.10.2 Aug 15, 2021
0.10.0 Nov 14, 2020
0.9.0 Dec 30, 2019
0.6.0 Mar 5, 2017

#55 in Game dev

Download history 6/week @ 2021-07-05 8/week @ 2021-07-12 19/week @ 2021-07-19 20/week @ 2021-07-26 22/week @ 2021-08-02 59/week @ 2021-08-09 30/week @ 2021-08-16 2/week @ 2021-08-23 2/week @ 2021-08-30 3/week @ 2021-09-06 30/week @ 2021-09-13 2/week @ 2021-09-20 51/week @ 2021-09-27 37/week @ 2021-10-04 20/week @ 2021-10-11 6/week @ 2021-10-18

86 downloads per month
Used in usi-run

MIT license

135KB
3.5K SLoC

shogi-rs

Github Actions Coverage Status crates.io docs.rs

A Bitboard-based shogi library in Rust. Board representation, move generation/validation and time control utilities.

Documentation

Usage

A library for implementing Shogi application.

shogi provides a various types and implementations for representing concepts and rules in Shogi. Most types can be created programatically while they can also be deserialized from / serialized to SFEN format. See USIプロトコルとは (What is the USI protocol?) for more detail about UCI protocol specification and SFEN format.

Examples

use shogi::{Move, Position};
use shogi::bitboard::Factory as BBFactory;
use shogi::square::consts::*;

BBFactory::init();
let mut pos = Position::new();

// Position can be set from the SFEN formatted string.
pos.set_sfen("lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1").unwrap();

// You can programatically create a Move instance.
let m = Move::Normal{from: SQ_7G, to: SQ_7F, promote: false};
pos.make_move(m).unwrap();

// Move can be created from the SFEN formatted string as well.
let m = Move::from_sfen("7c7d").unwrap();
pos.make_move(m).unwrap();

// Position can be converted back to the SFEN formatted string.
assert_eq!("lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL b - 1 moves 7g7f 7c7d", pos.to_sfen());

License

shogi-rs is licensed under the MIT license. Please read the LICENSE file in this repository for more information.

Dependencies

~0.7–1.2MB
~27K SLoC