Created
October 5, 2016 13:44
-
-
Save andreuinyu/da70d536429352abc39f356c4b7c224a to your computer and use it in GitHub Desktop.
Ruleta
This file contains 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
function [ bankrolls ] = ruleta(bankrollI, stakeI,apostes) | |
%bankrollI: diners amb els que comences a jugar | |
%stakeI: valor de l'aposta mínima | |
%apostes: número d'apostes a fer | |
close all | |
bankrolls = [bankrollI]; | |
stake = stakeI; | |
for i = 1:apostes | |
bankrollI = bankrollI - stake; | |
bankrolls = [bankrolls bankrollI]; | |
num = randi(37)-1; | |
if bankrolls(end) < 0 | |
break | |
end | |
if num == 0 | |
stake = 2*stake; | |
elseif mod(num,2) == 1 | |
stake = 2*stake; | |
else | |
bankrollI = bankrollI + 2*stake; | |
stake = stakeI; | |
end | |
end | |
plot(bankrolls) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment