Struct core::deck::Deck
[−]
[src]
pub struct Deck { /* fields omitted */ }Methods
impl Deck[src]
fn new() -> Deck
Returns a shuffled Deck.
fn simplify(&mut self)
Removes all cards from the deck that do not have a solid shading. This is useful as a deck for beginners.
fn is_empty(&self) -> bool
fn remainder(&self) -> usize
fn draw(&mut self, n: usize) -> Vec<Card>
impl Deck[src]
fn draw_guaranteeing_set(&mut self, hand: &[Card]) -> Option<Vec<Card>>
The smallest number of cards guaranteed to contain a Set is
21. However, the odds that there are no sets in 18 cards is so
low that it almost never happens in practice. As long as there
are at least 6 cards in the stock, we can doctor the deck to
guarantee that 18 cards will contain a Set:
15 (table) + 6 (stock) == 21
If there are only 3 more cards to deal, you could still get stuck with 18 cards, but at that point the game would be over.
In the worst case scenario, 15 cards are on the table, 6 remain
in the stock, and there's exactly 1 Set amongst those 21
cards.* There are 3 cases we need to handle:
1) Two cards from the Set are on the table, and one is in the
stock. We need to make sure that the one card in the stock is in
the next draw.
2) One card from the Set is on the table, and two are in the
stock. We need to make sure that both cards in the stock are in
the next draw.
3) All three cards in the Set are in the stock. We need to put
those three cards into the next draw.
*NOTE: It's possible that 21 cards always contain 2 or more sets. As far as I know, that's an open question.
Trait Implementations
impl Default for Deck[src]
impl Clone for Deck[src]
fn clone(&self) -> Deck
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more