Skip to content

Instantly share code, notes, and snippets.

@andreuinyu
Created October 5, 2016 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreuinyu/da70d536429352abc39f356c4b7c224a to your computer and use it in GitHub Desktop.
Save andreuinyu/da70d536429352abc39f356c4b7c224a to your computer and use it in GitHub Desktop.
Ruleta
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