Jump to content

RPG attributes generator: Difference between revisions

Added R.
m (Commodore BASIC: Corrected variables in dice sorting subroutine (lines 2000 through 2020).)
(Added R.)
Line 2,788:
<pre>Rolls: (11 16 10 13 12 15)
Total: 77</pre>
 
=={{header|R}}==
The base library already has an attributes function, so we avoid using that name. Otherwise, this is R's bread and butter.
<lang R>genStats <- function()
{
stats <- c(STR = 0, DEX = 0, CON = 0, INT = 0, WIS = 0, CHA = 0, TOT = 0)
for(i in seq_along(stats))
{
results <- sample(6, 4, replace = TRUE)
stats[i] <- sum(results[-which.min(results)])
}
if(sum(stats >= 15) < 2 || (stats[length(stats)] <- sum(stats)) < 75) Recall() else stats
}
print(genStats())</lang>
 
{{out}}
<pre>STR DEX CON INT WIS CHA TOT
9 13 16 11 14 15 88 </pre>
 
=={{header|Raku}}==
331

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.