Guest User

OD mana

a guest
Jan 27th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.96 KB | None | 0 0
  1. clear all
  2. close all
  3. maxpoolarr = [600:200:1400];
  4. maxhits = 100;
  5. numsims = 2000;
  6. cdf=zeros(numel(maxpoolarr),maxhits);
  7. for j = 1:numel(maxpoolarr)
  8.     maxpool=maxpoolarr(j);
  9.     endval = zeros(1,numsims);
  10.     for i = 1:numsims
  11.         pool=maxpool;
  12.         for endval(i) = 1:maxhits
  13.             pool=pool-100;
  14.             if (pool<100)
  15.                 break
  16.             end
  17.             if (rand < 0.4)
  18.                 pool=pool+maxpool*0.25;
  19.             end
  20.             if (pool>maxpool)
  21.                 pool=maxpool;
  22.             end
  23.         end
  24.     end
  25.     pdf = hist(endval,1:maxhits,100);
  26.     cdf(j,:) = cumsum(pdf);
  27. end
  28. figh=figure
  29. set(figh,'Position',[100, 100, 1280,800])
  30. hold all
  31. grid on
  32. grid minor on
  33. for i = 1:numel(maxpoolarr)
  34.     plot(cdf(i,(1:maxhits-1)));
  35. end
  36. legend(strcat(num2str(maxpoolarr'),' mana'))
  37. title('CDF for running out of mana on OD');
  38. xlabel('Maximum amount of consecutive hits')
  39. ylabel('Chance you are out of mana (%)')
Add Comment
Please, Sign In to add comment