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 个赞

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

2 个赞

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

6 个赞

Discourse AI 现在有一个相当有能力且富有创意的骰子掷骰器,例如 @random_picker_bot,请帮我掷一个 1d20+5?

另外,顺便为我的猫选一个随机名字。

3 个赞
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:

4 个赞

这里最大的优势在于你不需要学习任何特殊的语法,GPT-4 会为你搞定一切。这可能会让掷骰子变得有点昂贵,但 GPT 3.5 也能做得相当不错。

2 个赞

我们如何知道这种系统是否按我们预期的方式运行?它可能偏好奇数,或者偏好不掷出对子,或者任何其他情况。

1 个赞

您可以在 https://github.com/discourse/discourse-ai/blob/main/lib/ai_bot/tools/random_picker.rb 查看随机化代码。例如,掷骰子似乎由以下代码确定:

2 个赞

啊,非常感谢。我天真地以为是 LLM 在工作——接入某些过程代码是另一回事,在这种情况下是正确的答案!

聊天机器人也有类似的情况。如果你让它做数学题,它会调用一个确定性函数,而不是听凭机会。

2 个赞