when gf clicked repeat (length of [list v]) set [selector v] to (pick random (1) to (length of [list v])) add (item (selector) of [list v]) to [scrambled list v] delete (selector) of [list v] end
Last edited by zammer990 (2012-09-11 18:12:02)
Offline
Yeah it is possible
repeat (large number, eg 100) set [random v] to (pick random (1) to (length of [list v])) set [value v] to (item (random) of [list v]) delete (random) of [list v] insert (value) at (random) of [list v] endAnother, more complicated, way of doing it would be this:
repeat (length of [list v]) set [random v] to (pick random (1) to (length of [list v])) repeat until <not <[randomising v] contains (random)>> set [random v] to (pick random (1) to (length of [list v])) end add (random) to [randomising v] end set [random v] to (1) repeat (length of [list v]) add (item (item (random) of [randomising v]) of [list v]) to [shuffle v] change [random v] by (1) end delete [all v] of [list v] set [random v] to (1) repeat (length of [shuffle v]) add (item (random) of [shuffle v]) to [list v] end end
Last edited by Prestige (2012-09-11 18:23:21)
Offline
I've got a demo project that uses insert to build up a random sequential list - see if this helps at all
http://scratch.mit.edu/projects/Paddle2SeeFixIt/958900
Offline
Was the OP deleted? I thought it was someone asking for help.
Offline
Hmm... I just hope I can explain this properly.
You pick the first item in the list and remember the place it was in, then you pick a random number between 1 and the length of the list. You remember what that item was, then you swap that with the first item you chose, and the same for the other one.
Or download this and look at the scripts:
http://scratch.mit.edu/projects/TPAL125/2783196
Offline
TPAL125 wrote:
Hmm... I just hope I can explain this properly.
You pick the first item in the list and remember the place it was in, then you pick a random number between 1 and the length of the list. You remember what that item was, then you swap that with the first item you chose, and the same for the other one.
Or download this and look at the scripts:
http://scratch.mit.edu/projects/TPAL125/2783196
The method I posted would be a simpler one.
Offline
another method:
when gf clicked repeat (scrambling amount) set [chooser v] to (pick random (1) to (length of [list v])) set [chooser2 v] to (pick random (1) to (length of [list v])) set [temp v] to (item (chooser) of [list v]) replace item (chooser) of [list v] with (item (chooser2) of [list v]) replace item (chooser2) of [list v] with (temp)Is this solved?
Offline
zammer990 wrote:
when gf clicked repeat (length of [list v]) set [selector v] to (pick random (1) to (length of [list v])) add (item (selector) of [list v]) to [scrambled list v] delete (selector) of [list v] end
This is the easiest, just remember to delete all of scrambled list before you start.
Offline
Molybdenum wrote:
zammer990 wrote:
when gf clicked repeat (length of [list v]) set [selector v] to (pick random (1) to (length of [list v])) add (item (selector) of [list v]) to [scrambled list v] delete (selector) of [list v] endThis is the easiest, just remember to delete all of scrambled list before you start.
And add the items you want to be scrambled at the start, Assuming it's not user inputted
Offline
zammer990 wrote:
TPAL125 wrote:
Hmm... I just hope I can explain this properly.
You pick the first item in the list and remember the place it was in, then you pick a random number between 1 and the length of the list. You remember what that item was, then you swap that with the first item you chose, and the same for the other one.
Or download this and look at the scripts:
http://scratch.mit.edu/projects/TPAL125/2783196The method I posted would be a simpler one.
Mine works as well, though.
Offline