Advertisement
Guest User

Untitled

a guest
May 13th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. % clc
  2. %reg rolls = 18.82 pointbuy over 1000000 runs, ave stat of 12.244
  3. %Generates 6 4d6 minus the lowest roll and each bonus.
  4. Scores=(1:6);
  5. for j0=1:6
  6. for i0=1:4
  7. s(i0)=randi([1 6]);%This is the 4d6
  8. end
  9. [I N]=min(s);%Finds value (I)/index (N) of lowest d6 in array
  10. s(N)=0;
  11. Scores(j0)=sum(s);
  12. end
  13.  
  14. if abs(Scores-10)<=2
  15. Totalcost=sum(Scores-10);
  16. else
  17. end
  18.  
  19. cost=zeros(1,6);%Figuring the point buy
  20. for f0=1:6
  21. tempcost=0;
  22. if abs(Scores(f0)-10)<=2%for scores <=12, >=8
  23. cost(f0)=Scores(f0)-10;
  24. else
  25. if Scores(f0)>=13
  26. clear tmp
  27. tmp=Scores(f0);
  28. for i0=13:tmp
  29. tempcost=tempcost+2+floor((i0-10)/2);%Matlab "reads" right to left
  30. end
  31. cost(f0)=tempcost-2*(i0-13);
  32. else
  33. end
  34. if Scores(f0)<=7
  35. clear tmp
  36. tmp=Scores(f0);
  37. for j0=tmp:7
  38. tempcost=tempcost-2+floor((j0-10)/2);%Matlab "reads" right to left
  39. end
  40. cost(f0)=tempcost+2*(j0-tmp);
  41. else
  42. end
  43. end
  44. end
  45. Scores
  46. Bonus=floor((Scores-10)/2)
  47. cost
  48. Totalcost=sum(cost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement