I am making a program that will run a roulette style program 1000000 times. The program should give me an output with my average winnings per trip to the casino. I am starting with 315 dollars and the conditions for betting are: if I lose i will double my bet and play again. If I win, I will start my bid back at my first initial bid amount (5 dollars) I have created a random number generator and an equation to determine my probability, I have having trouble with the loop. while numbers are generating I am trying to have the program do the bidding for me and my results are less than successful. Any ideas? I realize now that one of my equations in the loop is incorrect, I am just concerned with getting the loop to work at the moment. Thanks!
A = 315 %starting amount of money
initial = 5 %Initial bet amount
WIN = 335 %Condition for a win
LOSE = 0 %Condition for loss
profit = 0
g = 0 %counter for random numbers when multiplied by %probability
N = ((log(A+5)-log(5))/log(2)) %Number of bets
Pwinner = (1 – (1/2^N))^4 %Probability of a win
a = initial * (2^N -1) %bid condition for a loss
Gwinner = (1 – (10/19)^N)^4 %probability of win with green slots
%Allow Green Slots?
x = input('Do you want to allow for the green slots (0=No, 1=Yes)? ');
if x == 0;
r = randi([1,36],[1000000 ,1]); round(r)else r = randi([1,38],[1000000 ,1]); round(r)end
fprintf('Please wait while computer simulates game 1000000 times');
%Solution while A < WIN && A > LOSE
g = Pwinner .* r; round(g); if g > 18; A = A - initial profit = (1/2^N) * A else fprintf('this isnt working') end
end
Best Answer