RPG attributes generator: Difference between revisions

Added XPL0 example.
m (→‎{{header|Phix}}: syntax coloured)
(Added XPL0 example.)
Line 3,945:
The six values are: [15, 16, 10, 12, 13, 13]
Their total is: 79
</pre>
 
=={{header|XPL0}}==
<lang XPL0>func Gen; \Return sum of the three largest of four random values
int I, R, Min, SI, Sum, Die(4);
[Min:= 7; Sum:= 0;
for I:= 0 to 4-1 do
[R:= Ran(6)+1; \R = 1..6
if R < Min then
[Min:= R; SI:= I];
Sum:= Sum+R;
Die(I):= R;
];
return Sum - Die(SI);
];
 
int Total, Count, J, Value(6);
[repeat Total:= 0; Count:= 0;
for J:= 0 to 6-1 do
[Value(J):= Gen;
if Value(J) >= 15 then Count:= Count+1;
Total:= Total + Value(J);
];
until Total >= 75 and Count >= 2;
Text(0, "Total: "); IntOut(0, Total); CrLf(0);
for J:= 0 to 6-1 do
[IntOut(0, Value(J)); ChOut(0, ^ )];
CrLf(0);
]</lang>
 
{{out}}
<pre>
Total: 79
13 17 11 10 16 12
</pre>
 
772

edits