Skip to content

Commit

Permalink
Merge pull request #116 from sfleischman105/Beta-Branch
Browse files Browse the repository at this point in the history
Update versions, Fix nightly breakage, slight optimizations
  • Loading branch information
sfleischman105 authored Jul 2, 2018
2 parents 7cf9320 + 2f010dc commit e535290
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 12 deletions.
5 changes: 2 additions & 3 deletions pleco/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pleco"
version = "0.4.2"
version = "0.4.3"
authors = ["Stephen Fleischman <[email protected]>"]
description = "A blazingly-fast chess library."
homepage = "https://github.com/sfleischman105/Pleco"
Expand Down Expand Up @@ -59,12 +59,11 @@ codegen-units = 4
[dependencies]
clippy = {version = "0.0.200", optional = true}
bitflags = "1.0.3"
rand = "0.5.0"
rand = "0.5.2"
rayon = "1.0.1"
num_cpus = "1.8.0"
prefetch = "0.2.0"
mucow = "0.1.0"
unreachable = "1.0.0"

[dependencies.lazy_static]
version = "1.0.0"
Expand Down
3 changes: 2 additions & 1 deletion pleco/src/board/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use std::option::*;
use std::{fmt, char,num};
use std::cmp::{PartialEq,max,min};
use std::hint::unreachable_unchecked;

use rand;

Expand Down Expand Up @@ -1947,7 +1948,7 @@ impl Board {
PieceType::Q => {
queen_moves(self.occupied() ^ src_bb, dst)
}
_ => unreachable!(),
_ => unsafe { unreachable_unchecked() }
};
(attacks_bb & opp_king_sq.to_bb()).is_not_empty()
}
Expand Down
3 changes: 2 additions & 1 deletion pleco/src/board/movegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
use std::mem;
use std::ptr;
use std::ops::Index;
use std::hint::unreachable_unchecked;

use board::*;

Expand Down Expand Up @@ -253,7 +254,7 @@ impl<'a, MP: MVPushable> InnerMoveGen<'a, MP>
GenTypes::NonEvasions => !self.us_occ,
GenTypes::Captures => self.them_occ,
GenTypes::Quiets => !(self.us_occ | self.them_occ),
_ => unreachable!()
_ => unsafe { unreachable_unchecked() }
};

self.generate_all::<L, G, P>(target);
Expand Down
4 changes: 3 additions & 1 deletion pleco/src/core/bitboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ use super::Player;
use std::mem;
use std::ops::*;
use std::fmt;
use std::hint::unreachable_unchecked;

/// 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)]
#[repr(transparent)]
pub struct BitBoard(pub u64);

impl_bit_ops!(BitBoard, u64);
Expand Down Expand Up @@ -373,7 +375,7 @@ impl RandBitBoard {
RandAmount::Sparse => self.prng.sparse_rand(), // Average 8 bits
RandAmount::VerySparse => self.prng.sparse_rand() & (self.prng.rand() | self.prng.rand()), // Average 6 bits
RandAmount::ExtremelySparse => self.prng.sparse_rand() & self.prng.rand(), // Average 4 bits
RandAmount::Singular => unreachable!()
RandAmount::Singular => unsafe {unreachable_unchecked()}
};
let count = popcount64(num) as u16;
if count >= self.min && count <= self.max {
Expand Down
3 changes: 2 additions & 1 deletion pleco/src/core/piece_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const SP_MASK: u16 = 0b0011_000000_000000;
/// A `BitMove` should never be created directly, but rather instigated with a `PreMoveInfo`. This is because
/// the bits are in a special order, and manually creating moves risks creating an invalid move.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[repr(transparent)]
pub struct BitMove {
data: u16,
}
Expand Down Expand Up @@ -116,7 +117,7 @@ pub enum MoveFlag {

/// A Subset of `MoveFlag`, used to determine the overall classification of a move.
#[derive(Copy, Clone, PartialEq, Debug)]
#[repr(u16)]
#[repr(u8)]
pub enum MoveType {
/// The move is "Normal", So its not a castle, promotion, or en-passant.
Normal = 0, //0b000x
Expand Down
1 change: 1 addition & 0 deletions pleco/src/core/sq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ use std::mem::transmute;

/// Represents a singular square of a chessboard.
#[derive(Copy, Clone, Default, Hash, PartialEq, PartialOrd, Eq, Debug)]
#[repr(transparent)]
pub struct SQ(pub u8);

impl_bit_ops!(SQ, u8);
Expand Down
1 change: 0 additions & 1 deletion pleco/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ extern crate rand;
extern crate rayon;
extern crate prefetch;
extern crate mucow;
extern crate unreachable;

pub mod core;
pub mod board;
Expand Down
8 changes: 4 additions & 4 deletions pleco_engine/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pleco_engine"
version = "0.1.3"
version = "0.1.4"
authors = ["Stephen Fleischman <[email protected]>"]
description = "A blazingly-fast Chess AI."
homepage = "https://github.com/sfleischman105/Pleco"
Expand Down Expand Up @@ -57,10 +57,10 @@ path = "src/lib.rs"
doctest = true

[dependencies]
pleco = { path = "../pleco", version = "0.4.2" }
pleco = { path = "../pleco", version = "0.4.3" }
clippy = {version = "0.0.200", optional = true}
chrono = "0.4.2"
rand = "0.5.0"
chrono = "0.4.4"
rand = "0.5.2"
num_cpus = "1.8.0"
prefetch = "0.2.0"
crossbeam-utils = "0.4.0"
Expand Down

0 comments on commit e535290

Please sign in to comment.