38 lines
1.1 KiB
Text
38 lines
1.1 KiB
Text
$ include "seed7_05.s7i";
|
|
|
|
const proc: main is func
|
|
local
|
|
var integer: count is 0;
|
|
var integer: total is 0;
|
|
var integer: attribIdx is 0;
|
|
var integer: diceroll is 0;
|
|
var integer: sumOfRolls is 0;
|
|
var array integer: attribute is 6 times 0;
|
|
var array integer: dice is 4 times 0;
|
|
begin
|
|
repeat
|
|
count := 0;
|
|
total := 0;
|
|
for key attribIdx range attribute do
|
|
for key diceroll range dice do
|
|
dice[diceroll] := rand(1, 6);
|
|
end for;
|
|
dice := sort(dice);
|
|
sumOfRolls := 0;
|
|
for diceroll range 2 to maxIdx(dice) do # Discard the lowest roll
|
|
sumOfRolls +:= dice[diceroll];
|
|
end for;
|
|
attribute[attribIdx] := sumOfRolls;
|
|
total +:= sumOfRolls;
|
|
if sumOfRolls >= 15 then
|
|
incr(count);
|
|
end if;
|
|
end for;
|
|
until total >= 75 and count >= 2;
|
|
writeln("Attributes:");
|
|
for key attribIdx range attribute do
|
|
writeln(attribIdx <& " ..... " <& attribute[attribIdx] lpad 2);
|
|
end for;
|
|
writeln(" ----");
|
|
writeln("Total " <& total lpad 3);
|
|
end func;
|