#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int twoify(int num, int times)
{
num *= 2;
if (times > 0)
{
times--;
return twoify(num, times);
}
return num;
}
int main()
{
srand(time(NULL));
const int BET = 1;
const int TIMES = 100000;
const int CHANCE = 50;
int wins = 0;
int losses = 0;
int wstreak = 0;
int lstreak = 0;
int cwstreak = 0;
int clstreak = 0;
for (int i = 0; i < TIMES; i++)
{
int num = rand() % 100 + 1;
if (num <= CHANCE) // win?
{
wins++;
cwstreak++;
clstreak = 0;
if (cwstreak > wstreak)
wstreak = cwstreak;
}
else
{
losses++;
clstreak++;
cwstreak = 0;
if (clstreak > lstreak)
lstreak = clstreak;
}
}
cout << "Wins: " << wins << "\tLosses: " << losses << endl;
cout << "Win Streak: " << wstreak << "\tLoss Streak: " << lstreak << endl;
cout << "Worst lose bet: " << twoify(BET, lstreak) << endl;
system("PAUSE");
cout << endl << endl;
return main();
}
In particular, the twoify()
function seems noobis. This is a martingale bet pattern, and basically every loss you double your previous bet until you win.