|
Post by adlc on Apr 30, 2020 8:48:45 GMT
Hi there,
I'm currently trying to select a random value between a set of values stored in variables (psytoolkit 3.0.0). Something like this :
set $valueA random 10 19 set $valueB random 20 29 set $valueC random 30 39
set $randValue random from $valueA $valueB $valueC But this piece of code doesn't work (compiling is fine but the experiment stops at this last line). I also tried to write "set $randValue $valueA $valueC" (for testing purpose) and it works more or less : $randValue always took the value of $valueA. Is this intended behaviour ?
This could actually be done alternatively (see below) but my experiment uses more values so it would be more difficult to write/read, and could take a lot more time to process) :
set $valueA random 10 19
set $valueB random 20 29
set $valueC random 30 39
while $randValue != $valueA and $randValue != $valueB and $randValue != $valueC set $randValue random 10 39 while-end Is there a way to select a random value from already set variables ? Could this be done in an alternative way ?
Thank you
|
|
|
Post by PsyToolkit on Apr 30, 2020 9:51:24 GMT
The "random from" instruction can currently only work with a set of fixed numbers, not variables.
Unfortunately. It would be nice to add that in a future version, but this is rarely needed (although I can see the benefit for your project).
I can think about it, but it will take a bit of time to implement it, so if there is an alternative, you may try that.
The while loop seems to work well?
|
|
|
Post by adlc on Apr 30, 2020 10:00:45 GMT
Thank you for the quick answer !
I will use the while alternative, it should work but I didn't test it yet and since I use a lot of variables I'm afraid it could take a longer time (relatively speaking) to run. In any case there is no urgent need for this addition. I already appreciate a lot all the recent improvement to Psytoolkit !
|
|