-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshoe.cpp
78 lines (69 loc) · 5.42 KB
/
shoe.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// SELF
#include <shoe.hpp>
// STANDARD LIBRARY
#include <vector>
#include <algorithm>
#include <random>
// Const to speedup; may not be worth
// TODO: test
const std::vector<int> Shoe::one_deck = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11};
const std::vector<int> Shoe::two_decks = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11};
const std::vector<int> Shoe::four_decks = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11};
const std::vector<int> Shoe::six_decks = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11,11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11};
const std::vector<int> Shoe::eight_decks = {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11};
std::default_random_engine Shoe::rng = std::default_random_engine {std::random_device{}()};
Shoe::Shoe(int num_decks) : Deck() {
this->num_decks = num_decks;
switch (this->num_decks) {
case 1:
this->cards = this->one_deck;
break;
case 2:
this->cards = this->two_decks;
break;
case 4:
this->cards = this->four_decks;
break;
case 6:
this->cards = this->six_decks;
break;
case 8:
this->cards = this->eight_decks;
break;
default:
for(int i = 0; i < this->num_decks; i++) {
this->cards.insert(this->cards.end(), this->one_deck.begin(), this->one_deck.end());
}
break;
}
shuffle();
}
Shoe::Shoe(int num_decks, bool shuffled) : Deck() {
this->num_decks = num_decks;
switch (this->num_decks) {
case 1:
cards = this->one_deck;
break;
case 2:
cards = this->two_decks;
break;
case 4:
cards = this->four_decks;
break;
case 6:
cards = this->six_decks;
break;
case 8:
cards = this->eight_decks;
break;
default:
for(int i = 0; i < this->num_decks; i++) {
this->cards.insert(this->cards.end(), this->one_deck.begin(), this->one_deck.end());
}
break;
}
if(shuffled) shuffle();
}
void Shoe::shuffle() {
std::shuffle(std::begin(this->cards), std::end(this->cards), rng);
}