Dice Formula

Simulated dice for role playing games
Post Reply
steve huge
Posts: 1
Joined: Sun Jun 10, 2012 11:48 pm
IQ Test: Orange

Dice Formula

Post by steve huge » Wed Jan 29, 2014 12:56 pm

Ok, I am terrible at the formulas, but I have managed to figure out the basics of what I want :) but... for the bigger rolls theres one more step I would like.

So far I have this

sort (20d10@)

this formula rolls 20d10 and then gives me the numbers sorted from low to high...

so for example the result looks like this

1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 5, 5, 5, 7, 7, 8, 8, 10

but what I actually want the result to look like is this

3x1
5x2
3x3
1x4
3x5
2x7
2x8
1x10

is there any way I can do that?

Thanks for any help people can give, I appreciate it...

Neil

gandreas
Immortal
Posts: 1464
Joined: Wed Feb 04, 2004 6:02 pm
Contact:

Re: Dice Formula

Post by gandreas » Thu Jan 30, 2014 5:17 pm

The need for something like this has been anticipated, so doing this is pretty compact:

Code: Select all

@x <- 20d10@.
@v <- unique(@x).
@c <- uniquec(@x).
@c + " x " + @v
unique() finds all the unique values in a list. uniquec() is similar, but find the corresponding counts of those unique values.

The magic is then in the last line - adding a value to a list results in adding that value to each element of the list, producing a new list (@c + " x " creates a new list with each element in @c with the string " x " appended to it). Adding two lists will add each element in the list ("pair wise"), producing a new list.

You could even shorten this to:

Code: Select all

@x <- 20d10@.
@uniquec(@x) + " x " + @unique(@x)

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests