Reply To: Random Number Generator

PennController for IBEX Forums Support Random Number Generator Reply To: Random Number Generator

#6014
Jeremy
Keymaster

Hello Callie,

Sorry for the late reply, I was away from the office last week. What you can do is generate the random number at the beginning of the experiment, but present it only at the end. Here’s a dummy experiment for illustration purposes:

PennController.ResetPrefix(null) // Shorten command names (keep this line here)

uniqueID = [1,2,3,4].map(v=>Math.floor((1+Math.random())*0x10000).toString(16).substring(1)).join('-');

Header(
    // void
)
.log( "ID" , uniqueID )

newTrial("intro", newButton("Hello").print().wait() )
newTrial("experiment", newButton("World").print().wait() )
SendResults()
newTrial("end", newText("your id: "+uniqueID).print(),newButton().wait() )

Let me know if you need assistance adapting this to your case

Jeremy