From 493a0b4ebe613e6c1a8aa4bb3d967831fc606ad4 Mon Sep 17 00:00:00 2001 From: Stephen Fleischman Date: Mon, 26 Mar 2018 15:30:27 -0700 Subject: [PATCH] Prepare `pleco` to 0.4.0 release. Signed-off-by: stephenf --- pleco/src/board/mod.rs | 14 +++++++++++--- pleco/src/bot_prelude.rs | 10 ---------- pleco/src/core/bitboard.rs | 2 +- pleco/src/core/mod.rs | 17 +++++++++-------- pleco/src/core/piece_move.rs | 1 + pleco/src/helper/prelude.rs | 6 ++++-- pleco_engine/src/search/mod.rs | 6 ++---- 7 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 pleco/src/bot_prelude.rs diff --git a/pleco/src/board/mod.rs b/pleco/src/board/mod.rs index b476dfa..a8d3480 100644 --- a/pleco/src/board/mod.rs +++ b/pleco/src/board/mod.rs @@ -324,11 +324,16 @@ impl Board { /// /// let board = Board::from_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1").unwrap(); /// assert_eq!(board.count_all_pieces(),32); + /// + /// + /// let obviously_not_a_fen = "This shouldn't parse!"; + /// let bad_board = Board::from_fen(obviously_not_a_fen); + /// assert!(bad_board.is_err()); /// ``` /// - /// # Panics + /// # Safety /// - /// The FEN string must be valid, or else the method will panic. + /// The FEN string must be valid, or else the method will return an Error. /// /// There is a possibility of the FEN string representing an unvalid position, with no panics resulting. /// The Constructed Board may have some Undefined Behavior as a result. It is up to the user to give a @@ -2025,7 +2030,6 @@ impl Board { } - fn min_attacker

(&self, to: SQ, stm_attackers: BitBoard, occupied: &mut BitBoard, attackers: &mut BitBoard) -> PieceType where P: PieceTrait { @@ -2063,6 +2067,8 @@ impl Board { /// Returns the piece that was moved from a given BitMove. /// + /// Simply put, this method will return the `Piece` at a move's from square. + /// /// # Safety /// /// Assumes the move is legal for the current board. @@ -2075,6 +2081,8 @@ impl Board { /// Returns the piece that was captured, if any from a given BitMove. /// + /// If the move is not a capture, `PieceType::None` will be returned. + /// /// # Safety /// /// Assumes the move is legal for the current board. diff --git a/pleco/src/bot_prelude.rs b/pleco/src/bot_prelude.rs deleted file mode 100644 index a24a963..0000000 --- a/pleco/src/bot_prelude.rs +++ /dev/null @@ -1,10 +0,0 @@ -//! Easy importing of all available bots. - -//pub use bots::RandomBot; -//pub use bots::MiniMaxSearcher; -//pub use bots::ParallelMiniMaxSearcher; -//pub use bots::AlphaBetaSearcher; -//pub use bots::JamboreeSearcher; -//pub use bots::IterativeSearcher; -// -//pub use tools::Searcher; \ No newline at end of file diff --git a/pleco/src/core/bitboard.rs b/pleco/src/core/bitboard.rs index 1358abb..fe5e3a1 100644 --- a/pleco/src/core/bitboard.rs +++ b/pleco/src/core/bitboard.rs @@ -35,7 +35,7 @@ use std::mem; use std::ops::*; use std::fmt; -/// Defines an object to define a bitboard. A `BitBoard` is simply a u64 where each +/// A `BitBoard` is simply a 64 bit long integer where each /// bit maps to a specific square. Used for mapping occupancy, where '1' represents /// a piece being at that index's square, and a '0' represents a lack of a piece. #[derive(Copy, Clone, Default, Hash, PartialEq, Eq, Debug)] diff --git a/pleco/src/core/mod.rs b/pleco/src/core/mod.rs index b2689d6..18b3688 100644 --- a/pleco/src/core/mod.rs +++ b/pleco/src/core/mod.rs @@ -196,6 +196,10 @@ pub enum GenTypes { } /// All possible Types of Pieces on a chessboard. +/// +/// For a representation of pieces considering color as well, see [`Piece`] +/// +/// [`Piece`]: ./enum.Piece #[repr(u8)] #[derive(Copy, Clone, PartialEq, Debug)] pub enum PieceType { @@ -225,14 +229,6 @@ impl PieceType { } } - pub fn as_option(self) -> Option { - if self == PieceType::None { - None - } else { - Some(self) - } - } - /// Returns if the piece is `PieceType::None` #[inline(always)] pub fn is_none(self) -> bool { @@ -299,6 +295,10 @@ impl fmt::Display for PieceType { // TODO: documentation /// All possible Types of Pieces on a chessboard, for both colors. +/// +/// For a representation of Only Pieces (with no color attached), see [`PieceType`] +/// +/// [`Piece`]: ./enum.PieceType #[repr(u8)] #[derive(Copy, Clone, PartialEq, Debug)] pub enum Piece { @@ -699,6 +699,7 @@ pub enum CastleType { QueenSide = 1, } +#[doc(hidden)] #[derive(Copy, Clone, PartialEq, Debug)] #[repr(u8)] pub enum Phase { diff --git a/pleco/src/core/piece_move.rs b/pleco/src/core/piece_move.rs index 4a6bd37..41a30d3 100644 --- a/pleco/src/core/piece_move.rs +++ b/pleco/src/core/piece_move.rs @@ -208,6 +208,7 @@ impl BitMove { } + /// Returns the promotion flag bits of a `PieceType`. #[inline(always)] fn promotion_piece_flag(piece: PieceType) -> u16 { match piece { diff --git a/pleco/src/helper/prelude.rs b/pleco/src/helper/prelude.rs index 63a30e8..7bb97ee 100644 --- a/pleco/src/helper/prelude.rs +++ b/pleco/src/helper/prelude.rs @@ -196,6 +196,8 @@ pub fn z_ep(sq: SQ) -> u64 { } /// Returns the Zobrish hash for a castling right. +/// +/// Undefined behavior will occur if the bits are greater than 15. #[inline(always)] pub fn z_castle(castle: u8) -> u64 { zobrist::z_castle(castle) @@ -223,14 +225,14 @@ pub fn psq(piece: Piece, sq: SQ) -> Score { psqt::psq(piece, sq) } -/// Returns the value of a piece for a player. If `eg` is true, it returns the end game value. Otherwise, +/// Returns the value of a `Piece`. If `eg` is true, it returns the end game value. Otherwise, /// it'll return the midgame value. #[inline(always)] pub fn piece_value(piece: Piece, eg: bool) -> Value { psqt::piece_value(piece, eg) } -/// Returns the value of a piece for a player. If `eg` is true, it returns the end game value. Otherwise, +/// Returns the value of a `PieceType`. If `eg` is true, it returns the end game value. Otherwise, /// it'll return the midgame value. #[inline(always)] pub fn piecetype_value(piece_type: PieceType, eg: bool) -> Value { diff --git a/pleco_engine/src/search/mod.rs b/pleco_engine/src/search/mod.rs index 36b5509..c20dec8 100644 --- a/pleco_engine/src/search/mod.rs +++ b/pleco_engine/src/search/mod.rs @@ -404,9 +404,9 @@ impl Searcher { if !self.stop() { let score_diff: i32 = best_value - self.previous_score; - let improving_factor: i64 = (185).max((630).min( + let improving_factor: i64 = (215).max((630).min( 353 - + 100 * self.failed_low as i64 + + 109 * self.failed_low as i64 - 6 * score_diff as i64)); time_reduction = 1.0; @@ -955,8 +955,6 @@ impl Searcher { } - // TODO: Implement this inside the main search - // Right now this is a stub. fn update_quiet_stats(&mut self, mov: BitMove, ss: &mut Stack, quiets: &[BitMove], bonus: i32) { if ss.killers[0] != mov {