What triggers an update of random numbers?
Hi all,
Please see attached worksheet. It is probably not the most efficient way of building this particular worksheet, but it started off basic and I have added to it as I've gone along.
My problem is that the "mult" variable (which is randomly generated) updates itself on any press of the 'Show' button. Most of the time this then changes the question just as it shows the answers, defeating the purpose. There are quite a few randomly generated numbers in the construction, but they all remain fixed until the UpdateConstruction[] command is run by the 'Next' button - it is only "mult" that updates.
'Show' button script comprises "ShowLayer[2]" and nothing else. "mult" only depends on "gresub(2)", which itself is randomly generated but doesn't update on the 'Show' button. Is there any way I can keep this dependency but stop the update?
Many thanks.
Hi
Sorry I can't reproduce this problem.
I use GGB 5.0.199, Desktop, HTML-Chrome, Windows 10
In the attachment
"Bild 1" is before press "show"
"Bild 2" is after press "show"
nothing has changed (also not with a few time)
Raymond
And now I have gone back into the file, I can't reproduce it myself either! :flushed: Behaves exactly as expected. There must have just been a little glitch that was causing the problem and exiting and reloading appears to have fixed it - I guess I probably should've done this before creating the thread!
Thank you for taking the time to test this, it is appreciated.
If you want more control over random numbers then instead of
UpdateConstruction[]
you can do
dummy = 0
a = RandomBetween[0, 10 + 0 * dummy]
then then to generate a new random number just
SetValue[dummy, 0]
In fact it's probably simpler to just do this
SetValue[a, RandomBetween[0,10]]
if you don't need UpdateConstruction[] to update the random numbers too
Thanks, Michael - they seem like sensible approaches for exercising full control over when variables are updated. I shall bear this in mind for future constructions.
Kind regards.
Comments have been locked on this page!