Dice with Letters, Icons, etc.

## Dice with Letters, Icons, etc.

 Tue Sep 21 16:28:15 2021   by   Matthew Burke A lot of games have dice whose faces have letters, icons, or other symbols instead of numbers on them; examples include Steve Jackson's Zombie Dice, Tony Go's Deep Space D6 (DSD6), or Richard Garfield's King of Tokyo.Of course you can always use Troll and mentally map the numbers that result to the symbols. But if you're going to use a \$2000 set of dice, you might as well eliminate as much of the mental work as possible :)You could use nested "if"s to do the conversion, although this gets tedious, particularly as the number of sides increases. Perhaps slightly easier is to pipe the output through a command line tool like sed (of course, I'm concentrating on command line Troll, not the web interface).If you want to roll multiple kinds of dice, things get a little...uh...dicey (sorry, couldn't resist :) since collections are printed in sorted order, you lose information on which dice is which.If you have only two kinds of dice, you can use Troll's pair operator: [3d6, 2d10] would yield something like [2 4 4, 2 8] and then with a little bit more complicated string manipulation you can do one transformation for the first set of numbers and a different one for the second set.If you have more than two types of dice, then the two possible solutions I've come up with are a little ugly and I'm wondering if somebody can suggest something a little cleaner.Solution 1: use nested pairs.For example, if I had three kinds of 6-sided dice and I wanted to roll two of each kind, I could do [ 2d6, [2d6, 2d6]]Parsing the output gets to be a drag.Solution 2: add different offsets to each type of dice.Using the same example as above:{ 2d6, 2d6 + 10, 2d6 + 20 }This isn't too bad. And parsing the output is easy.But I'm wondering if there's a nicer solution I'm overlooking. Tue Sep 21 19:51:08 2021   by   Matthew Burke Syntax error in the above. Should be{ 2d6, 2#(d6+10), 2#(d6+20) } Wed Sep 22 10:35:36 2021   by   Torben Not really.  You can't have collections of strings or pairs (since these were a late addition), which would allow something like `choose {"a", "b", "c"}`.  I have considered allowing this, but it requires a major overhaul of the code. Wed Sep 22 10:36:35 2021   by   Torben A bit easier would be to extend pairs to N-tuples, so you can write `[2d6,2d6,2d6]`.