Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support arbitarily sided dice #239

Open
xremming opened this issue Jan 17, 2022 · 4 comments
Open

Support arbitarily sided dice #239

xremming opened this issue Jan 17, 2022 · 4 comments

Comments

@xremming
Copy link

Is your feature request related to a problem? Please describe.
AnyDice supports arbitarily sided dice with syntax d{1,2,4,8} these are often handy, for example when you need some weirder values for "coin flips" e.g. d10 * d{1,1,2} would be d10 multiplied by two 1/3 of the time.

Describe alternatives you've considered
Very generic tool but in reality not needed that often. might allow the internals to change how e.g. fudge and exploding dice work.

@GreenImp
Copy link
Collaborator

This was actually partially discussed here #229 (comment)

Thinking about it, it could be useful to allow the StandardDice min value to be modified through notation, and for it to offset the sides / max value.

I think it should be fairly simple to implement, but I'd have to run some tests.

I'm not sure what the notation would be for something like that though. Any thoughts?

A couple of idea off the top of my head:

// using "db" for Dice with Base number
db0,3  // roll a 3 sides die, with a min value of `0` (0, 1, 2)
db4,2  // roll a 2 sided die, with a min value of `4` (4, 5)

// square brackets to define a range (Same rolls as above)
d[0, 2]  // roll a dice that has all values between 0, and 2 inclusive (0, 1, 2)
d[4, 5]  // roll a dice that has all values between 4, 5 inclusive (4, 5)

But with no conclusion.

I think what you're suggesting seems like a further enhancement of that suggestion.

@xremming
Copy link
Author

When implemented properly it could also be used to create multichoice rolls. For example to roll a random item from multiple tables (such as loot in D&D) you could do d{d8,d20,d100}, of course in that case you would also need to render which side the dice landed on somehow...

@GreenImp
Copy link
Collaborator

GreenImp commented Oct 22, 2022

Basing this off the examples on AnyDice, and how MathJS handles ranges, I think a reasonable syntax would be:

// roll a die with values between n1 and n2 inclusive
d{n1...n2}

// Same as above
d{n1:n2}}

// Same as above, but with specifying an optional step value
d{n1:s:n2}}

// roll a die with the specific values
d{n1, n2, n3}

For example:

// Roll a dice with a minimum value of 1 and a maximum of 6 (Same as `d6`)
d{1..6}

// Same as above
d{1:6}

// Roll a dice with a minimum of -1 and a maximum of 1 (A Fudge die)
d{-1..1}

// Same as above
d{-1:1}

// Roll a dice with a minimum of -0.5 and a maximum of 10.5, with a step of .25
d{-0.5:0.25:10.5}}

// Roll a die with specific values
d{2, 3, 3, 4}

We can't currently support die notation as a value (e.g. d{d8,d20,d100} as the parser can't handle this at the moment (See #206)

@ls-philippe-gamache
Copy link

ls-philippe-gamache commented Feb 28, 2024

Also, supporting none numbers sides, something like : 2d[blue, red, green] might return blue, green or red, red

In those case, I only see {cp} = working. For example 2d[blue, red, green]=green, or maybe something 2d[blue, red, green]double will give 1 is twice the same value appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants