-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Force return of average result? #140
Comments
Do you mean each individual roll should return the average value between the lowest and highest possible values? Something like:
Or do you want to be able to average the results of several dice rolls?
|
For my use case I'd be after the former - each die involved would roll an average result and any modifiers specified by the notation would be applied. I've read all of your excellent documentation but it seems that this is not something that's offered at present. As a short term solution I've opted to use droll just to have it translate the dice notation into an average result. droll makes this available via the output of its |
I'm glad you like the docs! You're right, there's currently no way of calculating average values, but I've got a few ideas:
What are your thoughts? |
I appreciate your thoughts on this. Ideally, I'd like to leave the input notation untouched for it to remain as standard as possible. My application will allow users to enter some notation, so not messing with this would be in my interest. I guess that rules out option 2 and possibly option 3 as it sounds like that may be heading in the direction of further custom notation. Unfortunately, option 1 doesn't get me any closer to benefiting from modifiers available in your library. What about the |
Yeah, I thought number 1 wouldn't really be an improvement on what you're getting with Droll. I may add it at some point anyway, just because I could see it potentially being useful for some things. I know you're not wanting to change the notation that you use but, the simplest thing to implement at the moment would be option 2 or 3 - personally I prefer option 3, as it will work with any dice. In terms of adding a property to the Out of interest, are you using the |
Currently I'm using neither :) Looking back at my initial evaluation of rpg-dice-roller though it seems I was using Looking back over option 2 above, I guess I could parse more standard notation and then convert this to use "mean dice" notation behind the scenes and before using it with I appreciate you still entertaining this idea! If it helps I could share a demo of what I'm working on, though I'll need to do that more privately atm. |
Yeah, seeing an example of what your doing would definitely be of benefit. Might help me think of some better solutions. How would you want to share? |
Great, thanks. I just pinged you a message through your website's contact form. |
Cheers Dan |
Just to say, I've implemented option 1 in PR #149 which will go out in 4.2.0. So dice now have an I'm still looking at the best solutions for your situation, so don't worry, It's not been forgotten! |
Just as a follow up from our conversation yesterday, I'm thinking this could work well in combination with #150. The requirement there is to have a min and max possible totals for a given notation, so I could use that to calculate the average. I'm thinking the average will be as a new property on the |
I've finished work on #150, which means I should be able to get this sorted now. |
And I've now added an You can use it like so: const diceRoll = new DiceRoll('4d8+1');
console.log(roller.averageTotal); // outputs 19 I'll be adding it to the docs, and it will go out in v4.3.0. Hopefully it will come in handy. Let me know if it's not what you're after. |
Yay! This and the changes in #150 are just the ticket. Can't wait to try it out. |
Ooof, just seen the timestamp from your last comment. Don't over do it! Thanks again. |
Great looking library here! Is there a way to return the average result for the input notation, rather than the actual result of each instance of the input notation?
E.g. Inputting
3d3
might return something like this:Whereas I'm interested in a way to force it to return the average outcome every time:
My use case is to hopefully use this library in a game probability calculator rather than as an actual roller in a game. I was looking at https://github.com/thebinarypenguin/droll but it's not seen much development of late and rpg-dice-roller has extra functionality that is really relevant to what I need.
The text was updated successfully, but these errors were encountered: