How to strip characters out of uuid to use as a random seed
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to strip characters out of uuid to use as a random seed
How to strip characters out of uuid to use as a random seed? So that I'm only left with numbers, since randomseed only uses numbers.
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: How to strip characters out of uuid to use as a random s
This worked for me, although I'm sure there's a fancier way to do it:
Code: Select all
on mouseUp
put empty into tSeed
put uuid() into tVar
repeat with x=1 to the number of characters in tVar
if char x of tvar is a number then
put char x of tvar after tSeed
else
put empty into char x of tvar
end if
end repeat
answer tseed
end mouseUp
Re: How to strip characters out of uuid to use as a random s
Thanks sefrojones. I'll give it a shot. Seems like it's doing the trick.
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: How to strip characters out of uuid to use as a random s
Is there a limit to the length of a randomseed? I'm trying to use (basically) the same script as i posted above, and for some reason when I set the randomseed to tSeed, it doesn't take. Any ideas?
edit: It seems like you can't set the randomseed to any number longer than 9 digits.......
edit: It seems like you can't set the randomseed to any number longer than 9 digits.......
Re: How to strip characters out of uuid to use as a random s
sefrojones wrote:Is there a limit to the length of a randomseed? I'm trying to use (basically) the same script as i posted above, and for some reason when I set the randomseed to tSeed, it doesn't take. Any ideas?
edit: It seems like you can't set the randomseed to any number longer than 9 digits.......
I tried your script so far and threw in a random text file to see what it looked like.
Code: Select all
put empty into tSeed
put uuid() into tVar
repeat with x=1 to the number of characters in tVar
if char x of tvar is a number then
put char x of tvar after tSeed
else
put empty into char x of tvar
end if
end repeat
## I wonder if this is even random
put any line of URL ("http://domain.com/totalrandom.txt") into tLine1
put tLine1 into field "fldRandom1"
Last edited by shawnblc on Mon Jun 23, 2014 6:33 am, edited 1 time in total.
Re: How to strip characters out of uuid to use as a random s
In the dictionary they have an example with a 7 digit number, but don't mention a limit.
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: How to strip characters out of uuid to use as a random s
I think I've got this figured out, here's what I've got now, and it seems to be working great.
If the randomseed is longer than 9 digits, it will continually arrive at the same "random" number
edit: or so it seems to me
Code: Select all
on mouseUp
put uuid() into tVar
repeat with x=1 to the number of characters in tVar
if char x of tvar is a number then
put char x of tvar after tSeed
if the number of chars of tSeed >=9 then exit repeat
end if
end repeat
replace space with empty in tSeed
set the randomseed to tSeed
Answer "randomseed:" && the randomseed&cr& "random:"&&random(100) & cr & "uuid:"&&tvar
end mouseUp
edit: or so it seems to me
Re: How to strip characters out of uuid to use as a random s
sefrojones wrote:I think I've got this figured out, here's what I've got now, and it seems to be working great.
If the randomseed is longer than 9 digits, it will continually arrive at the same "random" numberCode: Select all
on mouseUp put uuid() into tVar repeat with x=1 to the number of characters in tVar if char x of tvar is a number then put char x of tvar after tSeed if the number of chars of tSeed >=9 then exit repeat end if end repeat replace space with empty in tSeed set the randomseed to tSeed Answer "randomseed:" && the randomseed&cr& "random:"&&random(100) & cr & "uuid:"&&tvar end mouseUp
edit: or so it seems to me
Looks good. Gonna play with it. Like a kid with a new toy. lol
Re: How to strip characters out of uuid to use as a random s
sefrojones wrote:I think I've got this figured out, here's what I've got now, and it seems to be working great.
If the randomseed is longer than 9 digits, it will continually arrive at the same "random" numberCode: Select all
on mouseUp put uuid() into tVar repeat with x=1 to the number of characters in tVar if char x of tvar is a number then put char x of tvar after tSeed if the number of chars of tSeed >=9 then exit repeat end if end repeat replace space with empty in tSeed set the randomseed to tSeed Answer "randomseed:" && the randomseed&cr& "random:"&&random(100) & cr & "uuid:"&&tvar end mouseUp
edit: or so it seems to me
Not so random for me. When I close and remove from memory and close out LC. Restart, I get the same results.
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: How to strip characters out of uuid to use as a random s
Same here, I had never heard of uuid() until Simon mentioned it in your other postshawnblc wrote:
Looks good. Gonna play with it. Like a kid with a new toy. lol

--Sefro
Last edited by sefrojones on Mon Jun 23, 2014 6:57 am, edited 1 time in total.
Re: How to strip characters out of uuid to use as a random s
Know whatcha mean, I've heard of uuid's and namespaces (I definitely don't understand them), but I don't do this for a living like some guys on here. Just a hobby. With any luck one day I'll make something a few find useful and they might just be willing to pay for it.sefrojones wrote:Same here, I had never hard of uuid() until Simon mentioned it in your other postshawnblc wrote:
Looks good. Gonna play with it. Like a kid with a new toy. lol
--Sefro

I was getting better results with what you had the first time around. Seemed a lot more random, even when I went from reading lines from a 10,000 line file to one with less than 20 lines.
-
- Livecode Opensource Backer
- Posts: 447
- Joined: Mon Jan 23, 2012 12:46 pm
Re: How to strip characters out of uuid to use as a random s
That's weird, when i try to use my first script it works to seperate the numbers form the UUID but when I try to set the randomseed to Tseed, It will only use tSeed as the randomseed if it is less than 9 digits. If it is more than 9 digits it will not throw an error, but the randomseed is set to a different number (the same one every time), and random(100) will give the same result every time. When i set it to only use the first 9 digits of tSeed, it seemingly works fine......This is on Ubuntu 14.04 (which I am very new to) I will probably play around with this a bit more in windows 7 tomorrow.shawnblc wrote: I was getting better results with what you had the first time around. Seemed a lot more random, even when I went from reading lines from a 10,000 line file to one with less than 20 lines.
--Sefro
Re: How to strip characters out of uuid to use as a random s
..........
Last edited by [-hh] on Wed Aug 13, 2014 2:11 pm, edited 1 time in total.
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 10053
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to strip characters out of uuid to use as a random s
@ shawnblc: The randomSeed property can be useful in cases where you want psuedorandomization across a repeatable series, but it not generally regarded as being able to increase the breadth of distribution for simulating true randomness. As Hermann suggested, the randseed setting the engine does at the beginning of each session is generally viewed as sufficient.
What problems did you encounter with the default randomseed?
What problems did you encounter with the default randomseed?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to strip characters out of uuid to use as a random s
When using randsomseed, closing the program & removing from memory, then restarting the stack I'd get the same repeated line using randomseed or using any line. Both on OSX 10.93 and Windows 7 (vmware). Anytime my stack is called I'd like it truly random. Not a repeat of the same sequence.FourthWorld wrote: What problems did you encounter with the default randomseed?