Improve dice rolling for discourse-narrative-bot

Although @discobot has a dice roller, it’s too simple. It’s not yet capable of rolling complex dice and formulas for specific needs. So, I’d like to improve this feature and make it possible to run dice like 1d20+5, 1d20+2 + 2d12-1, 5d10k2 and so on…

I submitted this PR and would very much appreciate reviews and thoughts about it. Thanks! :slight_smile:

https://github.com/discourse/discourse/pull/7381

4 Likes

Hi! To find out what I can do, say @discobot display help.

2 Likes

Shoo! I don’t want to talk to you… ¬¬

6 Likes

Discourse AI now has a reasonably capable and creative dice roller, for example @random_picker_bot , how about rolling a 1d20+5 for me ?

Also while at it pick a random name for my cat.

3 Likes
Random Picker

Picking from ["1-20"], picked: [5]

Random Picker

Picking from ["Whiskers,Mittens,Socks,Shadow,Simba,Leo,Oliver,Luna,Bella,Max"], picked: ["Shadow"]

For your adventurous roll of 1d20+5, the dice landed on a 5, which adds up to a grand total of 10!

And for your future feline friend, the Random Picker has decreed its name shall be Shadow. Sounds like a kitty destined for stealthy midnight adventures, doesn’t it? :cat::sparkles:

3 Likes

The big advantage here is that you don’t need to learn any special syntax, GPT-4 just figures it out for you. It can make dice rolling a tad expensive, but GPT 3.5 does a reasonable job as well.

1 Like

How could we know if this kind of system is doing what we expect? It might prefer odd numbers, or prefer not to roll doubles, or anything really.

You can check the randomizing code at discourse-ai/lib/ai_bot/tools/random_picker.rb at main · discourse/discourse-ai · GitHub. For instance, dice rolls appear to be determined by:

2 Likes

Ah, many thanks. I had naively assumed the LLM was doing the work - being plumbed into some procedural code is a different story and in this case the right answer!

Similar thing on Chatbot. If you ask it to do maths it will call a deterministic function instead of leaving it up to chance.

1 Like