Limited rerolls?

Limited rerolls?

 Tue Dec 24 23:59:47 2013   by   whereswalden How would one implement a system with a limited number of rerolls? The below expression shows an attempt that DOESN'T work:rerolls:=4;foreach x in {1,1,1,1,1} do   rerolls:=rerolls - 1;  rerolls3 3 3 3 3: 100% Wed Dec 25 07:08:27 2013   by   whereswalden I think I've come up with a solution, but it's rather inelegant, and doesn't expand to limited numbers of rerolls greater than 1.function run(v) = max foreach x in different v do count x=vN := 5;S := 6;rerolls:=2;roll:= N d S;sets := roll -- different roll;if (0 = count sets) then  toreroll:= roll pick rerolls;  call run((count toreroll) d6 U (roll -- toreroll)) else if ((N-1) = count sets) then  call run(roll)else  toreroll:=(roll drop sets) pick rerolls;  call run((count toreroll) d6 U (roll -- toreroll))The key is that "roll -- different roll" yields "{}" if no dice matched, N-1 results if all the dice matched, and the values of dice that matched in all other cases. In the else case, reroll any M dice from the pool without any of the dice that are in sets, where M is the number of rerolls you can make by subtracting them from the set then adding that many new dice to the set.I've saved this result under "ORE with rerolls". Wed Dec 25 07:09:24 2013   by   whereswalden My previous solution does expand to rerolls greater than one, but it's still inelegant. Curse my lack of proofreading! Fri Dec 27 00:12:08 2013   by   Torben I'm not entirely sure what it is you want to do.  It looks like (but I'm not sure) that you are allowed to pick up and reroll M dice of your choice, sort of like in Yahtzee. The difficulty comes from deciding which dice to reroll: If all match, you don't want to reroll any, if none match, reroll any M dice.  That much seems obvious.  If there are at least M unmached dice, you want to reroll M of these, but what if, say, you have two pairs and one unmatched die?  Do you roll only the unmatched die, or do you reroll one pair to get a better chance of increasing the other pair to a triple (or more)?  If I understand the ORE system right, only one set is used, so the latter seems like the best option.  If so, the general strategy is: Keep the largest set and reroll as many of the remaining dice as you are allowed.  Since the values of the other dice don't matter. you can simply roll min{M, number of unmatched dice} dice and count how many are equal to the dice in the set.  And since the probabilities are the same regardless of what that value is, you can just count ones.  In total, the below should do it:`N := 5;S := 6;rerolls := 2;roll := N d S;set := max foreach x in roll do count x=roll;set + count 1 = (max {0, min {rerolls, N-set}})#d S`Does that sound like what you wanted to do? Mon Jan 6 21:05:14 2014   by   whereswalden Thanks for the response, Torben!I actually was curious about how rerolls would affect secondary sets, so I wanted to wait to apply max to the pool until the rerolls had already been added. It looks like the solution you posted hinges on being able to apply max early. (I saw similar code in one of the examples provided with Troll.) Tue Jan 7 16:12:36 2014   by   whereswalden Thanks for the response, Torben!I actually was curious about how rerolls would affect secondary sets, so I wanted to wait to apply max to the pool until the rerolls had already been added. It looks like the solution you posted hinges on being able to apply max early. (I saw similar code in one of the examples provided with Troll.) Tue Jan 7 16:13:01 2014   by   whereswalden whoops, sorry for the repost.

New message:
 Topic: Posted by:

Type the values of the dice shown below: