Zeroclickinfo-goodies: Dice: Set upper limit on max dice rolls and number of sides per dice

Created on 8 Mar 2017  路  13Comments  路  Source: duckduckgo/zeroclickinfo-goodies

Problem

When the Dice Goodie is given an extremely large number of sides for a dice roll, the DuckDuckGo UI breaks.

Eg. https://duckduckgo.com/?q=roll+6d12000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Solution

We should:

  1. Limit the max number of simultaneous dice rolls to 10
  2. Limit the max number of sides for a given dice to 31

Get Started

Resources

https://duck.co/ia/view/dice

Bug Highest Impact Tasks High Perl Other

Most helpful comment

Maybe look into the traffic data for > 10 dice or > 31 sides?

@nalinbhardwaj I checked, but we don't have much info for this IA because it triggers very little. The few queries I saw were related to rolling a single dice a few times. e.g. "roll a dice 4 times"

We'll be OK with using sane limits. I can't see what practical use someone has for rolling a 100+ sided dice, or rolling more than 10 die simultaneously.

Any dice roll result that involves scientific notation is just silly :)

We can always increase the limits if needed, but I don't expect we'll need to

All 13 comments

I'm not sure what the reason is, probably something related to overflow, but it seems to break when rolls or faces are greater than 10^200, if this is of help to anyone. example

Actually just checked properly, the rolls in the internals of the IA are all inf in such queries(overflow). Is it best to just ignore such queries and not return instead of breaking the page?

I've made a fix for this in nalinbhardwaj/dice-overflow-fix and also added a couple tests to check it. If everyone thinks it's best to not return anything in case of overflow, I'll make a PR with those changes. @8084 @pjhampton thoughts?

I just chatted with @moollaza. Rather than try identity infinite numbers, we should enforce a hard limit to the number of die.

@pjhampton that would still cause breaking of this query and I'm not sure why it's a worse idea to check infinity than imposing hard limits?

@nalinbhardwaj let's just set a very sane upper limit on the number of and the max sides for the dice.

I can we can limit to 10 dice, and max of 31 sides according to https://commons.wikimedia.org/wiki/Dice_by_number_of_sides

@moollaza I don't see a very good point in limiting the search engine capabilities when we should be able to support those queries. Maybe look into the traffic data for > 10 dice or > 31 sides?

Just my opinion though. I can make a PR if that's the final decision. :)

Maybe look into the traffic data for > 10 dice or > 31 sides?

@nalinbhardwaj I checked, but we don't have much info for this IA because it triggers very little. The few queries I saw were related to rolling a single dice a few times. e.g. "roll a dice 4 times"

We'll be OK with using sane limits. I can't see what practical use someone has for rolling a 100+ sided dice, or rolling more than 10 die simultaneously.

Any dice roll result that involves scientific notation is just silly :)

We can always increase the limits if needed, but I don't expect we'll need to

I don't think the side count should be limited. Actually I was not aware of the rules saying that each dice must have maximum 31 sides.

Someone would probably call me a strange person, but I like to kill my time rolling a dice until I guess the number. And if there would be no more than 31 sides, ddg roll function will be pretty useless for this purpose.

I think the best idea that keeps in account requests such as @8084's might be to limit sides and rolls at much higher constants(something like 10^4). Thoughts @pjhampton @moollaza ?

Thoughts @pjhampton @moollaza ?

We have a random number Goodie that can be used for what @8084 describes: https://duckduckgo.com/?q=random+number+between+1+and+1000&ia=answer

It only generates a single random number, but I see no reason why it can't be extended to provide multiple random numbers.

I don't see why a dice roll Instant Answer should deal with such large numbers though, especially when it's very unlikely to ever be used.

For now, let's go with my recommendation so we can fix this bug. We can debate if the limits for the dice Goodie should be increased after the bug is fixed 馃槂

Hi @moollaza - I'm interested in working on this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GuiltyDolphin picture GuiltyDolphin  路  15Comments

pjhampton picture pjhampton  路  17Comments

unhammer picture unhammer  路  14Comments

rushsteve1 picture rushsteve1  路  13Comments

moollaza picture moollaza  路  24Comments