Created
July 23, 2017 07:13
-
-
Save fireattack/02fb79daa6618d0155263ab2c037d74f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
iter = 50000; | |
gold_result = zeros(1, iter); | |
gold_odd = 0.1; | |
initial_dust = 2000; | |
for method = 1:2 | |
for i = 1:iter | |
bag = 0; | |
gold = 0; | |
dust = initial_dust; | |
if method == 2 % Buy 50-dust pack | |
while bag >=1 || dust >=50 | |
if dust >= 50 | |
bag = bag + floor(dust/50); | |
dust = mod(dust, 50); | |
end | |
gold = gold + bag; | |
dust = dust + 8*bag; | |
bag = 0; | |
end | |
end | |
% Buy normal instead | |
while bag >=1 || dust >=10 | |
if dust >= 10 | |
bag = bag + floor(dust/10); | |
dust = mod(dust, 10); | |
end | |
bag = bag -1; | |
if rand < gold_odd | |
gold = gold +1; | |
dust = dust + 3+2; | |
else | |
dust = dust + 6; | |
end | |
end | |
gold_result(i) = gold; | |
end | |
if method == 1 | |
fprintf('Open normal pack only: %.2f±%.2f\n', mean(gold_result), std(gold_result)) | |
else | |
fprintf('Open 50-dust pack only: %.2f±%.2f\n', mean(gold_result), std(gold_result)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment