Hi! I made a program to analyze a roulette strategy. It uses the strategy with a range of starting amounts (many times for each), and outputs profit to a file. The numbers should be different for every starting amount, and presumably should increase as the amount of starting funds increases until it reaches an upper limit. Unfortunately, m output is not at all like that. What is wrong?
// Roulette.cpp : This program will accumulate data for graphical analysis of the roulette strategy
usingnamespace std;
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <fstream>
int main(void)
{
int sum = 0;
int outcome[500];
int betCount = 1;
int startingBet;
int bet;
int startingMoney;
int endingMoney;
int money;
int profit = 0;
int interval;
int finalTotal[100];
int result;
// First a friendly introduction
cout << "What are the minimum starting funds? ";
cin >> startingMoney;
cout << "What are the maximum starting funds? ";
cin >> endingMoney;
cout << "what is the interval of increment?";
cin >> interval;
cout << "what is your starting bet? ";
cin >> startingBet;
bet = startingBet;
ofstream myfile ("money.txt", ios::out | ios::trunc);
if (myfile.is_open()) ;
else cout << "Unable to open file";
srand (time(NULL));
for(; startingMoney < endingMoney; startingMoney+=interval)
{
for (int i=0; i < 100; i++)
{
money = startingMoney;
/* initialize outcome: */
for (int j=0; j < 500; j++) outcome[j] = rand() % 380;
// now the betting algorithm
while (money >= bet)
{
betCount++;
if (outcome[betCount] > 179)
{
money = money + bet;
bet = startingBet;
profit = profit + money - startingMoney;
money = startingMoney;
}
else
{
money = money - bet;
bet = bet * 2;
}
if ((betCount > 100 && outcome[betCount] > 179) || bet > 500) break;
}
finalTotal[i] = money + profit - startingMoney;
profit = 0;
betCount = 0;
}
for (int k=0; k < 100; k++) sum = sum + finalTotal[k];
result = sum/100;
myfile << result << "\n";
}
myfile.close();
return 0;
}