For anydice.com, is there a way to set a total number for three rolls?


I am very, very new to writing code and working on designing a RPG. As part of that, I am trying to do a simulation of three weighted dice rolls, ranging from 1-12 where I set the limit of how much the total of all three rolls can be. Meaning, I want to limit the total that any set of three rolls can give me to 12.

I am interested in the actual results of the dice and not just their sum so 3/3/3 is different from 4/4/1.

If the sum of the dice would be above 12 then the die making it go above 12 would be rerolled until this is not the case.

As an example:

  • If you rolled 5/5 on the first two dice, the third die would be rolled until it was either a 1 or 2.
  • If you rolled 1/1 on the first two dice, the third die would be rolled until it was a number 1-10.

I have the dice weighted according to the percentages I need. I just have no idea how to do the language to limit the total.

Here’s what I have thus far:

W: {  1:12,  2:14,  3:18,  4:18,  5:17,  6:8,  7:8,  8:1,  9:1,  10:1,  11:1,  12:1 } output dW 

Any help would be GREATLY appreciated!