-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
172 lines (150 loc) · 6.39 KB
/
main.cpp
File metadata and controls
172 lines (150 loc) · 6.39 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include <iostream>
#include <ostream>
#include <set>
#include <algorithm>
#include <random>
#include "Card.h"
#include "Deck.h"
// Функция вычета выданных карт из колоды, чтобы не продублировать их на доске.
void deck_minus_hand(std::vector<Card>& deck, std::vector<Card>& hand) {
for (auto &c : hand) { deck.erase(std::remove(deck.begin(), deck.end(), c), deck.end()); }
//pr(deck);
}
void oesd_multiplies(std::vector<uint64_t>& oesd, std::vector<Card>& deck) {
oesd.clear();
// we need one suit only:
unsigned long s = deck.size() / 4;
uint64_t oesd_in_deck;
// Начиная с двойки (нам нужны двухсторонние дро) идём до короля
// и считаем произведение value_of_cardue по 4 карты в масти:
for (int i = 0; i < s - 3; ++i) {
oesd_in_deck = deck[i].value_of_card * deck[i + 1].value_of_card * deck[i + 2].value_of_card *
deck[i + 3].value_of_card;
oesd.push_back(oesd_in_deck);
}
}
void straight_multiplies(std::vector<uint64_t>& straights, std::vector<Card>& deck) {
straights.clear();
//we need one suit only:
unsigned long s = deck.size() / 4 + 1; //размер масти для цикла
uint64_t multuplies;
// Начиная с туза (А1345) идём до T (TJQKA)
// и считаем произведение value_of_cardue по 5 карт в масти:
for (int i = 0; i < s; ++i) {
multuplies = deck[(i + s) % s].value_of_card * deck[(i + s + 1) % s].value_of_card *
deck[(i + s + 2) % s].value_of_card * deck[(i + s + 3) % s].value_of_card *
deck[(i + s + 4) % s].value_of_card;
//std::cout << multuplies << std::endl;
straights.push_back(multuplies);
}
}
// Выбираем те OESD в которых есть наши сданные карты:
void only_hand_oesd(std::vector<uint64_t>& oesd,
std::vector<Card>& hand,
std::vector<uint64_t>& oesd_minus) {
for (auto &num : oesd) {
if (!(num % hand[0].value_of_card) | !(num % hand[1].value_of_card)) {
oesd_minus.push_back(num);
}
}
}
// Выбираем те стриты, в которых участвуют наши карты:
void only_hand_straights(std::vector<uint64_t>& strights,
std::vector<Card>& hand,
std::vector<uint64_t>& strights_minus) {
for (auto &num : strights) {
if (!(num % hand[0].value_of_card) | !(num % hand[1].value_of_card)) {
strights_minus.push_back(num);
}
}
}
// комбинации карт как произведения простых чисел (основная теорема арифметики):
long multiply_value_of_cards(std::vector<Card>& slice) {
uint64_t value_of_cardue = 1;
for (auto &i : slice) { value_of_cardue *= i.value_of_card; }
return value_of_cardue;
}
// тоже самое с маcтями:
long multiply_suits(std::vector<Card>& slice) {
uint64_t suits = 1;
for (auto &i : slice) { suits *= i.suit_of_card; }
std::cout << suits;
return suits;
}
void generateSlice(std::vector<Card>& deck, std::vector<Card>& desk, int size) {
desk.clear();
std::sample(deck.begin(),
deck.end(),
std::back_inserter(desk),
size,
std::mt19937{std::random_device{}()});
}
unsigned long long
getCombinations(std::vector<unsigned long long> parent,
std::vector< unsigned long long>::iterator startPosition,
int sizeCombination,
std::set<unsigned long long> combinations) {
}
int main() {
// std::vector<Card> deck52 = {
// "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "Ts", "Js", "Qs", "Ks", "As",
// "2h", "3h", "4h", "5h", "6h", "7h", "8h", "9h", "Th", "Jh", "Qh", "Kh", "Ah",
// "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "Td", "Jd", "Qd", "Kd", "Ad",
// "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c", "Tc", "Jc", "Qc", "Kc", "Ac"
// };
//
// std::vector<Card> hand = {"Td", "Jc"};
//
// /// вектор со всеми возможными OESD в колоде.
// std::vector<uint64_t> oesd;
// oesd_multiplies(oesd, deck52); /// заполнилcи его
//
// /// отфилтровали OESD, оставив т.е., в которых есть сданные на руки карты
// std::vector<uint64_t> oesd_with_hand;
// only_hand_oesd(oesd, hand, oesd_with_hand);
//
// /// вектор со всеми возможными стритами в колоде.
// std::vector<uint64_t> strights;
// straight_multiplies(strights, deck52);
//
// /// отфилтровали стриты, оставив те, в которых есть сданные на руки карты
// std::vector<uint64_t> strights_with_hand;
// only_hand_straights(strights, hand, strights_with_hand);
//
// std::vector<Card> flop; ///вектор с первыми тремя картами стола.
//
// deck_minus_hand(deck52, hand); ///раздали карты.
//
// int two_pair = 0;
// int one_pair = 0;
// int oesd_hand = 0;
// int iteration = 10000;
//
// for (int i = 0; i < iteration; ++i) {
// generateSlice(deck52, flop, 3);
//
// long mult_flop = multiply_value_of_cards(flop);
//
// if (!(mult_flop % (hand[0].value_of_card * hand[1].value_of_card))) {
// ++two_pair;
//
// } else if (!(mult_flop % hand[0].value_of_card) || !(mult_flop % hand[1].value_of_card)) {
// ++one_pair;
//
// } else {
// for (auto c : oesd_with_hand) {
// if (!(mult_flop * hand[0].value_of_card * hand[1].value_of_card % c)) {
// ++oesd_hand;
// break;
// }
// }
// }
// }
//
// std::cout << "Количество пар: " << 100*(float)one_pair/(float)iteration << "%" << std::endl;
// std::cout << "Количество двух пар: " << 100*(float)two_pair/(float)iteration << "%" << std::endl;
// std::cout << "Количество OESD: " << 100*(float)oesd_hand/(float)iteration << "%" << std::endl;
//
// Deck* deck = new Deck();int n=5;
return 0;
}