Created
May 8, 2019 16:05
-
-
Save kosbar/71f38d8763d9d6d2472c6068dcca3ca8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <ostream> | |
| #include <cmath> | |
| #include <set> | |
| #include <algorithm> | |
| #include <random> | |
| #include <iostream> | |
| using namespace std; | |
| template <class T> | |
| void pr(vector<T>& koloda){ | |
| cout << "koloda.size(): " << koloda.size() << endl; | |
| cout << "koloda.capacity(): " << koloda.capacity() << endl; | |
| std::cout << "vector: " << '\n'; | |
| for(int i = 0; i < koloda.size(); ++i){ std::cout << i << ": " << koloda[i] << ' ';} | |
| std::cout << '\n'; | |
| } | |
| void koloda_minus_hand(vector<long>& koloda, vector<long>& hand){ | |
| for(auto c : hand){ | |
| remove(koloda.begin(),koloda.end(),c); | |
| } | |
| pr(koloda); | |
| } | |
| void koloda_Generation (vector<long>& koloda, long* startCards, int sizeDeck) { | |
| koloda.clear(); | |
| pr(koloda); | |
| koloda.assign(startCards, startCards+sizeDeck); | |
| //pr(koloda); | |
| } | |
| void full_Deck_Generation(vector<long>& koloda, vector<long>& deck, default_random_engine& eng){ | |
| deck.clear(); | |
| uniform_int_distribution<int> distribution(0,koloda.size()); | |
| int j; | |
| vector<long int>::iterator it; | |
| for(int i = 0; i < 5; ++i){ | |
| j = distribution(eng); | |
| deck.push_back(koloda[j]); | |
| cout << koloda[j] << endl; | |
| it = find(koloda.begin(),koloda.end(),koloda[j]); | |
| koloda.erase(it); | |
| cout << koloda[j] << endl; | |
| } | |
| } | |
| void flop_Deck_Generation(vector<long>& koloda, vector<long>& deck, default_random_engine& eng, vector<long>& hand){ | |
| // if(koloda.size() < 52) { | |
| // set_u | |
| // } | |
| random_shuffle(koloda.begin(), koloda.end()); | |
| deck.clear(); | |
| uniform_int_distribution<int> distribution(0,koloda.size()); | |
| int j; | |
| vector<long>::iterator it; | |
| for(int i = 0; i < 3; ++i){ | |
| j = distribution(eng); | |
| deck.push_back(koloda[j]); | |
| it = find(koloda.begin(),koloda.end(),koloda[j]); | |
| koloda.erase(it); | |
| } | |
| } | |
| void make_OESD_multiplies(long *startCards, int N, vector<long>& oesd) { | |
| long card; | |
| long oesd_in_deck = 1; | |
| for (int i = 0; i < N - 2; ++i) { | |
| for (int j = i; j < i + 4; ++j) { | |
| card = (startCards[j % 13]) % (10000); | |
| //cout << card << endl; | |
| oesd_in_deck *= card; | |
| } | |
| //cout << oesd_in_deck << endl; | |
| oesd.push_back(oesd_in_deck); | |
| oesd_in_deck = 1; | |
| } | |
| } | |
| void make_STRIGHT_multiplies(long *startCards, int N, vector<long>& stright) { | |
| long card; | |
| long oesd_in_deck = 1; | |
| for(int i = 0; i < N-3; ++i){ | |
| for(int j = i; j < i+5; ++j) { | |
| card = (startCards[j % N]) % (10000); | |
| //cout << card << endl; | |
| oesd_in_deck *= card; | |
| } | |
| //cout << oesd_in_deck << endl; | |
| stright.push_back(oesd_in_deck); | |
| oesd_in_deck = 1; | |
| } | |
| } | |
| long multiply_deck(vector<long>& deck){ | |
| long mult = 1; | |
| for(auto i : deck){ | |
| mult *= (i % 10000); | |
| } | |
| return mult; | |
| } | |
| void minus_oesd_hand(vector<long>& oesd, vector<long>& hand, vector<long>& oesd_minus){ | |
| for(auto c : oesd){ | |
| // cout<<"elem of oesd: " << c << endl; | |
| // cout << "c%(hand[0]%10000): " << c%(hand[0]%10000) << " c%(hand[1]%10000): " << c%(hand[1]%10000) << endl; | |
| if(!(c%(hand[0]%10000)) | !(c%(hand[1]%10000))){ | |
| // cout << "---------------------------" << endl; | |
| // cout << "c%(hand[0]%10000): " << c%(hand[0]%10000) << endl; | |
| // cout << "c%(hand[1]%10000): " << c%(hand[1]%10000) << endl; | |
| oesd_minus.push_back(c); | |
| } | |
| } | |
| } | |
| int main() { | |
| long _koloda52[52] = { 10011, 10013, 10017, 10019, 10023, 10029, 10031, 10037, 10041, 10043, 10047, 10053, 10059, | |
| 20011, 20013, 20017, 20019, 20023, 20029, 20031, 20037, 20041, 20043, 20047, 20053, 20059, | |
| 30011, 30013, 30017, 30019, 30023, 30029, 30031, 30037, 30041, 30043, 30047, 30053, 30059, | |
| 40011, 40013, 40017, 40019, 40023, 40029, 40031, 40037, 40041, 40043, 40047, 40053, 40059 }; | |
| long _koloda36[] = { 10011, 10029, 10031, 10037, 10041, 10043, 10047, 10053, 10059, | |
| 20011, 20029, 20031, 20037, 20041, 20043, 20047, 20053, 20059, | |
| 30011, 30029, 30031, 30037, 30041, 30043, 30047, 30053, 30059, | |
| 40011, 40029, 40031, 40037, 40041, 40043, 40047, 40053, 40059 }; | |
| vector<long>oesd; /// вектор со всеми возможными OESD в короде. | |
| vector<long>stright; /// вектор со всеми возможными стритами в колоде. | |
| vector<long>flop; ///вектор с картами стола. | |
| vector<long>koloda; ///вектор колоды (все карты сразу) откуда рандомим карты стола. | |
| vector<long>hand; ///розданные карты. | |
| vector<long> oesd_with_hand; ///из всех вариантов OESD оставили только те, в которых есть сданные на руки карты | |
| default_random_engine generator; ///генератор случайных чисел | |
| make_OESD_multiplies(_koloda52, 13, oesd); | |
| make_STRIGHT_multiplies(_koloda52, 13, stright); | |
| hand.push_back(10043); | |
| hand.push_back(10047); | |
| //сгенерировали колоду, раздали руку (вычли карты из колоды). | |
| koloda_Generation(koloda, _koloda52, 52); | |
| koloda_minus_hand(koloda, hand); | |
| // | |
| // minus_oesd_hand(oesd,hand,oesd_with_hand); | |
| // int _oesd = 0; | |
| // | |
| // for(int i = 0; i < 1000001; ++i){ | |
| // | |
| // flop_Deck_Generation(koloda, flop, generator); ///раздали флоп (первые три карты стола). | |
| // | |
| //// cout << multiply_deck(hand) << endl; | |
| //// cout << multiply_deck(flop) << endl; | |
| // long flops_hand_multi = multiply_deck(hand) * multiply_deck(flop); | |
| // //cout << "flops_hand_multi: " << flops_hand_multi << endl; | |
| // for(auto c : oesd_with_hand){ | |
| // cout << "flops_hand_multi: " << | |
| // _oesd += (int)!(flops_hand_multi % c); | |
| // } | |
| // } | |
| // | |
| // cout << _oesd << endl; | |
| cout << "Hello my man!"; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment