Skip to content

Commit

Permalink
Prepare pleco to 0.4.0 release.
Browse files Browse the repository at this point in the history
Signed-off-by: stephenf <stephenf@cs.washington.edu>
  • Loading branch information
sfleischman105 committed Mar 31, 2018
1 parent 47dee65 commit 493a0b4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
14 changes: 11 additions & 3 deletions pleco/src/board/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2025,7 +2030,6 @@ impl Board {
}



fn min_attacker<P>(&self, to: SQ, stm_attackers: BitBoard, occupied: &mut BitBoard,
attackers: &mut BitBoard) -> PieceType
where P: PieceTrait {
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
10 changes: 0 additions & 10 deletions pleco/src/bot_prelude.rs

This file was deleted.

2 changes: 1 addition & 1 deletion pleco/src/core/bitboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
17 changes: 9 additions & 8 deletions pleco/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -225,14 +229,6 @@ impl PieceType {
}
}

pub fn as_option(self) -> Option<PieceType> {
if self == PieceType::None {
None
} else {
Some(self)
}
}

/// Returns if the piece is `PieceType::None`
#[inline(always)]
pub fn is_none(self) -> bool {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -699,6 +699,7 @@ pub enum CastleType {
QueenSide = 1,
}

#[doc(hidden)]
#[derive(Copy, Clone, PartialEq, Debug)]
#[repr(u8)]
pub enum Phase {
Expand Down
1 change: 1 addition & 0 deletions pleco/src/core/piece_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pleco/src/helper/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions pleco_engine/src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 493a0b4

Please sign in to comment.