Random ChainBuilder for each cycle inside .forever loop

Hi guys. I am executing a scenario where I need to continuously fire up weighed random actions, the same thing that
does. The only problem is that randomSwitch cannot operate inside the forever loop and this is exactly where I need it to be.

I tried to circumvent this by adding an own Scala value with own random distribution, but that does not seem to be evaluated during runtime. Any ideas? Maybe it was a bad choice of course in the first place.

My code follows:


class EFT extends BaseScenario {

def r = new scala.util.Random

override def scenarioBuilder = scenario(getClass.getSimpleName)
.forever(getAction) // <— the step is only calculated once during compilation

var getAction: ChainBuilder = {
var c = r.nextDouble() * 100

def getChance(percent: Double): Double = {
c = c - percent

if (getChance(27.7) < 0) { Log.putEvents }
else if (getChance(18.3) < 0) { Log.putBinary }
else if (getChance(17.2) < 0) { Loop.list }
else if (getChance(14.7) < 0) { Key.listIncomingRequests }
else { Account.get }