Wed Dec 24 23:08:00 2014 by Jake |

I'm trying to examine a multivariate calculation that examines one of the new metamagic feats. I'm usually pretty good at using troll (and thank you again for an awesome tool); but because of the varying "flavors" of changes going on, and some edge-case funkiness I might need a hand composing the function if possible. the ability reads as follows: "When you roll damage for a spell, you can spend 1 sorcery point to reroll a number of the damage dice up to your Charisma modifier (minimum of one). You must use the new rolls." I'm looking to examine how using that ability would increase damage potential. My 3 variables are" "X" The maximum amount of dice you are allowed to reroll [Typ 1-5] higher better "Y" The total number of "N"-sided dice of damage the spell allots. Ignore Ys > X "Z" The risk tolerance level of the player (It is statistically optimal to reroll any/all dice in the bottom half of the die's possible outcomes [1,2,3 on d6], but often people are unwilling to reroll 5 on d10s or 5&6 on d12s. A Z of 0 will reroll as many dice in the bottom half of their outcome range as possible. A Z of -1 (or lower) will reroll dice on level lower than the bottom half [only 1&2 on D6] and a Z of +1 (and higher) will reroll possible additional dice [1,2,3 AND 4 on a D6] With 1's always being rerolled when possibles and max-values "N" never being rerolled. Hopefully this part makes sense without being over explained lol. My final/ideal output will be a 5x5 table of values (reroll values 1-5 on one axis v/s die types 4,6,8,10,12) that shows the change in average damage incurred by using the feat for each of those 25 combinations. [with a different table being necessary for each different risk-level "Z" value; unless I do a 3d grid] But for right now I would just like a properly constructed expression that would incorporate all "typical" values for those 4 variables and give a single average damage output. I can do a table with X,Y,&N; but have yet to get one that incorporates Z working properly. If you have any questions or need any additional information let me know; and I thank you for any help in advance. |

Sat Dec 27 12:39:44 2014 by Torben |

I believe the following will do the trick:`N := 6; \ sides on die` |

Sun Dec 28 18:10:24 2014 by Jake |

Amazing! your solution not only handles all the overruns and edge cases I was having problems with; but is so much more elegant than the cludge I had cobbled together. My only question is when considering rerolls, does it start with the lowest value and work up (to give the highest yielded sum) Ie: [if I have a result of [7,8,1,8,9,2,1,3,4] and its going to reroll 3 dice of less than or equal to 4; it should choose the [1,1,2] and not pick randomly from the [1,1,2,3,4,] I believe from the way it reads that it does, but just wanted to double check. Thank you again for your help. P.S. I also had an option or two for the way troll works if you were interested. |

Mon Dec 29 16:40:38 2014 by Torben |

Yes, it starts from the smallest dice. This is done by keeping the ((count lo) - X) largest of the small dice and rerolling X dice. |