I am trying to figure out how to write an expression for a specific kind of roll. You roll d12, on a 12 you reroll and keep rerolling on 12s. When you finally get a roll less than 12 you calculate the result as (last roll) * (2 ^ (number of 12s rolled)). However if the first roll is 11 you roll again. If you get anything but 11 the result is 0. If you get an 11 the result is -1. pseudocode: d12 -> die; die? 1-10: die -> result 11: d12 -> die die? 11: -1 -> result 1-10 | 12: 0 -> result 12: 2 -> multiplier; d12 -> die A: die? 1-11: die * multiplier -> result 12: multiplier * 2 -> multiplier; d12 -> die; goto A Is there a way to express this?