diff --git a/src/cards/card.rs b/src/cards/card.rs index 549a0bf..dbb5a7a 100644 --- a/src/cards/card.rs +++ b/src/cards/card.rs @@ -2,10 +2,10 @@ use super::rank::Rank; use super::suit::Suit; #[cfg(not(feature = "shortdeck"))] -const CARD_COUNT_IN_DECK: usize = 52; +pub const CARD_COUNT_IN_DECK: usize = 52; #[cfg(feature = "shortdeck")] -const CARD_COUNT_IN_DECK: usize = 36; +pub const CARD_COUNT_IN_DECK: usize = 36; /// Card represents a playing card /// it is a tuple of Rank and Suit @@ -21,8 +21,13 @@ impl Card { } pub fn draw() -> Card { use rand::Rng; - let ref mut rng = rand::thread_rng(); - Card::from(rng.gen_range(0..CARD_COUNT_IN_DECK) as u8) + let rng = &mut rand::thread_rng(); + let suit = rng.gen_range(0..4) as u8; + #[cfg(not(feature = "shortdeck"))] + let rank = rng.gen_range(0..13) as u8; + #[cfg(feature = "shortdeck")] + let rank = rng.gen_range(4..13) as u8; + Card::from((Rank::from(rank), Suit::from(suit))) } } diff --git a/src/cards/hands.rs b/src/cards/hands.rs index 1613962..9cee3cc 100644 --- a/src/cards/hands.rs +++ b/src/cards/hands.rs @@ -14,12 +14,6 @@ pub struct HandIterator { mask: u64, } -#[cfg(not(feature = "shortdeck"))] -const CARD_COUNT_IN_DECK: usize = 52; - -#[cfg(feature = "shortdeck")] -const CARD_COUNT_IN_DECK: usize = 36; - impl HandIterator { /// returns the size of the iterator /// by some cheap combinatorial calculations @@ -122,6 +116,8 @@ impl From<(usize, Hand)> for HandIterator { #[cfg(test)] mod tests { + use crate::cards::card::CARD_COUNT_IN_DECK; + use super::*; #[test] diff --git a/src/clustering/layer.rs b/src/clustering/layer.rs index dcf2fd6..4044b49 100644 --- a/src/clustering/layer.rs +++ b/src/clustering/layer.rs @@ -3,13 +3,11 @@ use super::datasets::AbstractionSpace; use super::datasets::ObservationSpace; use crate::cards::isomorphism::Isomorphism; use crate::cards::observation::Observation; -use crate::cards::observations::ObservationIterator; use crate::cards::street::Street; use crate::clustering::abstraction::Abstraction; use crate::clustering::histogram::Histogram; use crate::clustering::metric::Metric; use crate::clustering::xor::Pair; -use petgraph::algo::isomorphism; use rand::distributions::Distribution; use rand::distributions::WeightedIndex; use rand::rngs::StdRng;