Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % clc
- %reg rolls = 18.82 pointbuy over 1000000 runs, ave stat of 12.244
- %Generates 6 4d6 minus the lowest roll and each bonus.
- Scores=(1:6);
- for j0=1:6
- for i0=1:4
- s(i0)=randi([1 6]);%This is the 4d6
- end
- [I N]=min(s);%Finds value (I)/index (N) of lowest d6 in array
- s(N)=0;
- Scores(j0)=sum(s);
- end
- if abs(Scores-10)<=2
- Totalcost=sum(Scores-10);
- else
- end
- cost=zeros(1,6);%Figuring the point buy
- for f0=1:6
- tempcost=0;
- if abs(Scores(f0)-10)<=2%for scores <=12, >=8
- cost(f0)=Scores(f0)-10;
- else
- if Scores(f0)>=13
- clear tmp
- tmp=Scores(f0);
- for i0=13:tmp
- tempcost=tempcost+2+floor((i0-10)/2);%Matlab "reads" right to left
- end
- cost(f0)=tempcost-2*(i0-13);
- else
- end
- if Scores(f0)<=7
- clear tmp
- tmp=Scores(f0);
- for j0=tmp:7
- tempcost=tempcost-2+floor((j0-10)/2);%Matlab "reads" right to left
- end
- cost(f0)=tempcost+2*(j0-tmp);
- else
- end
- end
- end
- Scores
- Bonus=floor((Scores-10)/2)
- cost
- Totalcost=sum(cost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement