1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//! # eschac - a library for computing chess moves
//!
//! eschac implements fast legal move generation and a copy-make interface that enforces at compile
//! time that no illegal move is played, with no runtime checks and no potential panics.
//!
//! ## Overview
//!
//! In eschac, a chess position is represented with the [`Position`](position::Position) type.
//! [`Position::new`](position::Position::new) returns the starting position of a chess game, and
//! arbitrary positions can be built using the [`Setup`](setup::Setup) type. This type must be
//! validated and converted to [`Position`](position::Position) with
//! [`Setup::into_position`](setup::Setup::into_position). Legal moves are generated using the
//! [`Position::legal_moves`](position::Position::legal_moves) method or obtained from chess
//! notation like [`UciMove`](uci::UciMove) or [`San`](san::San). Moves are represented with the
//! [`Move<'l>`](position::Move) type, which holds a reference to the origin position to ensure
//! that the move is not played on another one. Finally, moves are played with
//! [`Move::make`](position::Move::make) which returns a new [`Position`](position::Position), and
//! on it goes.
//!
//! ## Example
//!
//! ```
//! # (|| -> Result<(), Box<dyn std::error::Error>> {
//!
//! use eschac::prelude::*;
//!
//! // read a position from a text record
//! let setup = Setup::from_text_record("7k/4P1rp/5Q2/5p2/1Pp1bP2/8/r4K1P/6R1 w - -")?;
//! let position = setup.into_position()?;
//!
//! // read a move in algebraic notation
//! let san = "Ke1".parse::<San>()?;
//! let m = san.to_move(&position)?;
//!
//! // play the move (note the absence of error handling)
//! let position = m.make();
//!
//! // generate all the legal moves on the new position
//! let moves = position.legal_moves();
//! for m in moves {
//! // print the UCI notation of each move
//! println!("{}", m.to_uci());
//! }
//! # Ok(()) });
//! ```
//!
//! ## Comparison with [shakmaty](https://crates.io/crates/shakmaty)
//!
//! shakmaty is another Rust library for chess processing. It is written by Niklas Fiekas, whose
//! work greatly inspired the development of eschac. For most purposes, shakmaty is probably a
//! better option, as eschac comes short of its miriad of features.
//!
//! Both libraries have the same core features:
//! - vocabulary to describe the chessboard (squares, pieces, etc.)
//! - parsing and editing positions
//! - parsing standard move notations
//! - fast legal move generation and play
//!
//! **eschac** distinguishes itself with:
//! - a focus on performance
//! - a more compact board representation
//! - its use of the borrow checker to guarantee only legal moves are played
//!
//! **shakmaty** will be more suitable for a lot of applications, with:
//! - vocabulary to describe and work with games, not just positions
//! - insufficient material detection
//! - PGN parsing
//! - Zobrist hashing
//! - Syzygy endgame tablebases
//! - chess960 and other variants
//! - etc.
extern crate alloc;
pub
pub
pub
pub
/// The eschac prelude.