Created
February 16, 2015 14:27
-
-
Save mckomo/8fd294179f95a4eba41b to your computer and use it in GitHub Desktop.
Roulette progression strategy simulator
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 <random> | |
#include <iostream> | |
#define START_CREDITS 1000 | |
#define PROGRESSION_RATION 2 | |
#define MINIMAL_BET 0.5 | |
bool is_odd(int result) | |
{ | |
return result % 2 == 1; | |
} | |
int main() | |
{ | |
std::random_device rd; | |
std::mt19937 gen(rd()); | |
std::uniform_int_distribution<> dis(0, 36); | |
float credits = START_CREDITS; | |
float bet = MINIMAL_BET; | |
int bet_count = 0; | |
int result = 0; | |
int win_count = 0; | |
while (credits > 0) | |
{ | |
bet_count++; | |
win_count += result = dis(gen) % 2; | |
if (result == 1) | |
{ | |
credits += bet; | |
bet = MINIMAL_BET; | |
} | |
else | |
{ | |
credits -= bet; | |
bet *= PROGRESSION_RATION; | |
if (bet > credits) | |
{ | |
bet = credits; | |
} | |
} | |
std::cout << "\r" << "Credits :" << credits << ", round: " << bet_count << ", result: " << result % 2 << ", winning ration: " << (float) win_count / bet_count; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment