basicer / dicey

A dice probability calculator.
https://dicey.js.org
7 stars 1 forks source link

Documentation question: '@' and multiplying two probability clouds #1

Open nstephenh opened 10 months ago

nstephenh commented 10 months ago

What does the "@" operator do exactly? I'm looking to calculate warhammer saves, which would be (number of wounds)d6cs>3 for example, where number of wounds is the cloud from (number of hits)d6cs>3, and number of hits is another cloud. I think this would be output (d6cs>3)d6cs>3 , but that gives me Cannot read properties of undefined (reading 'values') "@" does seem to do something close to what I want for one die, output (1d6cs>3)@(1d6cs>3) gives a 75,25 split, but it doesn't appear to work with multiple dice, and I don't quite understand what it does.

nstephenh commented 9 months ago

I still don't understand what "@" does but I did figure out what I was trying to do with * and then, instead of setting the number of dice on each roll, using "repeat" on the whole expression.

basicer commented 9 months ago

The @ operator comes from anydice, and it gets the nth element in a set. For example 2@3d6 would get the middle die of the 3d6 (dice sets are sorted highest to lowest). I don't think it applies to what you're trying to do.

For 10 hits, it seems like ((10)d6cs>3)d6cs>3 would be the correct formula. I'll see if I can figure out why its causing an error. repeat(d6cs>3, 10d6cs>3) would also work, but I get the same error there too.

nstephenh commented 9 months ago

Some errors appeared to be coming from the parser, so I circumvented it by creating the parsed output object manually. The values I had returned didn't seem to be accurate, but perhaps I messed up something else with my logic. (repeat(d6,2d6cs>=4))cs>=4

image-22.png