Darwinbots Forum

Code center => Suggestions => Topic started by: Greven on June 28, 2005, 04:15:52 PM

Title: Regarding the seed value function!
Post by: Greven on June 28, 2005, 04:15:52 PM
Thx for adding the seed value function, very nice.

But I have an idea. What about having the seed value function show in bottom for the sim, were bot number etc. is showed?

Also when seed the sim with a timer, why dont we show the timer at the start of sim in this nice tiny place, then we can re-play time-seeded sims?
Title: Regarding the seed value function!
Post by: PurpleYouko on June 28, 2005, 04:53:04 PM
Except that timer seeded sims get reseeded on every cycle from the new timer value.

Kind of hard to reproduce that doncha think?
Title: Regarding the seed value function!
Post by: Numsgil on June 28, 2005, 08:40:51 PM
I think I fixed that bug actually.  (Bug only in that it's not necessary to reseed a sim with a new seed).

Should be possible.
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 08:45:13 AM
I don't see how you can reproduce a timer randomized sim unless you have removed the "randomize timer" command from the main loop.

This will make the random seed change depending on a bunch of different things such as Processor speed, other programs running, how fast DB is running, number of robots and many others.

You just can't reproduce all those factors and that is why a timer reseed is a lot more random than a manual reseed.

I can see why you would want to remove the timer reseed for running manually seeded models but in a timer reseeded model you want as much (pseudo) randomness as possible so you need to reseed as often as you can. Every cycle works well for me. That is the way it has always been and I see no reason to change that.
Title: Regarding the seed value function!
Post by: Numsgil on June 29, 2005, 11:39:28 AM
See, that's the fallacy.  You only need to seed a random function once, and ever after it will produce a string of random numbers that bear no statistical correlation with each other.  However, these numbers are only guarenteed to be random in the long run.  The smaller sample size you take from each seed, the less statistically random it becomes (that is, it's possible patterns will develop).

Trust me, I've spent alot of time studying random number genrators (about 2 weeks solid back in the day.  So maybe alot of time isn't quite accurate.)
Title: Regarding the seed value function!
Post by: Botsareus on June 29, 2005, 02:50:14 PM
PY, check this out:
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 04:18:31 PM
I have spent a fair old time on it myself.

I started messing with random stuff on a Commodore VIC 20 (back when there were still wooly mathoths wandering about)
1981 I think it was.

The random number generator in that wasn't too bad if you reseeded to the timer. If you didn't reseed it regularly it would generate a sequence of numbers that would repeat after about 64,000 calls on the rnd function. It was pretty easy to see the pattern by making graphics move about.

Using "randomize timer" (yes it was exactly the same syntax even back then) it was impossible to see any visible pattern.

Later I bought an Atari 800 thinking it would be better (more memory. faster processor and all that) It sucked!  <_<  The random sequence repeated every 16,000 calls and there was no "randomize timer" function at all!  :angry:

By the time I had an Atari ST and an Amiga in the very late 80s, the random functions were good enough that I had to work really hard to find the patterns. With randomize timer I couldn't detect any at all, no matter how long I sampled random numbers.

With the PC I haven't done any really large studies but I have yet to see the sequence repeat either with or without "randomize timer" so in that respect it really doesn't need to be called more than once.

However, the fact that putting in the same seed number twice gives an absolutely reproducable simulation kind of proves that the numbers aren't truly random. But then we all knew that anyway didn't we.

Putting "randomize timer" into the program once and storing the value is just the same as manually seeding it except you don't get the choice initially. But the sequence is reproducable so long as you know the seed.

Using "randomize timer" on every cycle makes the whole thing utterly unpredictable. It is the closest thing to true random numbers that you will ever get from a PC since it is constantly reseeded by numbers that are beyond anyones control or knowledge, or even ability to calculate. You cannot possibly know what the timer will read in 100 game cycles from now.
For a start it will run at different rates on different computers. Secondly, the slightest fluctuation in any of 100s of different factors can momentarily slow down the PC so that the next seed will be something other than what you predicted.

Windows runs so much crap in the background that one or other of the myriads of processes going on, is going to grab just that little bit more processor power for a nanosecond and screw up the timer by a tiny fraction.

Basically it is just a whole lot more random that way even if you can't really tell the difference.  :)
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 04:31:13 PM
Quote
PY, check this out:
Bots

What exactly is this supposed to prove?  :blink:

I am perfectly capable of making my own program to make pretty colored circular flower thingies.

What is your point?

Is it that randomizing to the timer makes no apparent difference to the way it forms?

So what? I never claimed that you  could see the difference. I just said that there IS a difference.

Incidentally your code won't run as is. You have to make a form with all the appropriately named control buttons first and I can't be bothered to.   :D
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 04:39:19 PM
here is a fun little excel spreadsheet that I made a while back to simulate gaussian distributions in a pinball game.

check it out just for the heck of it. (kind of irrelevent really but fun)
Title: Regarding the seed value function!
Post by: Botsareus on June 29, 2005, 07:27:04 PM
lol what?

All my buttons are there PY , what do you mean there is no buttons?

Second I was showing you that  one makes a flower thingy; and the other one spreads it out nice and even? But gess witch one makes the flower thingy?

Quote
Incidentally your code won't run as is.

Well it better be ran as is , and actualy click my buttons this time that I labeled really childlishly but like hell really appropreatly.

I feel like  :pokey: <--- that guy
Title: Regarding the seed value function!
Post by: Botsareus on June 29, 2005, 07:35:08 PM
Pinball heh I thought that was a vedio game , I could not figure out how to control anything exsept the start button, and delay.
Title: Regarding the seed value function!
Post by: Botsareus on June 29, 2005, 07:36:33 PM
Quote
Is it that randomizing to the timer makes no apparent difference to the way it forms?

NO!!!!!!!!!!!!!!!!!!! NEVER!!!!!!!!!!!


Randomizing the timer too often is a bad bad idea, need I say more?
Title: Regarding the seed value function!
Post by: Numsgil on June 29, 2005, 07:38:05 PM
I won't pretend to know how VB runs random numbers, but if it's anything like modern random number sequence generators, the period is quite large (I think in the billions).

So you just don't need to reseed it more than once. If you can find something to the contrary, I'll of course change my opinions, but I'm fairly certain reseeding the random function continuously actually decreases it's statistical randomness ( a wierd thing, I know).
Title: Regarding the seed value function!
Post by: Botsareus on June 29, 2005, 07:54:09 PM
AND I GOT PROVE OF WHAT NUM JUST SAYED , AND I POSTED IT TOO.
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 08:50:00 PM
Well that was freaky. :wacko:

When I clicked the download button earlier while I was at work, it opened up a text file directly into internet explorer. There was no forms, no buttons and no visual basic. Just a bunch of text.

Now when I click the button I get a VB program with forms and buttons just like you said Bots.

I don't see a damn bit of difference in the randomness of the dots whether we are reseeding or not.

The one thing your program does show is that reseeding on each cycle is very expensive in processor time. The program slows to about 1/10 of its speed when reseeding on my PC
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 08:53:38 PM
Quote
So you just don't need to reseed it more than once. If you can find something to the contrary, I'll of course change my opinions, but I'm fairly certain reseeding the random function continuously actually decreases it's statistical randomness ( a wierd thing, I know).

Wouldn't know anything about its statistical randomness. I am not one for advanced stats anyway. Makes my brain hurt.

I don't doubt that it will take billions of calls to repeat the sequence and as I said before, nobody will ever be able to see or probably even detect the difference in the randomness whether we reseed to the timer or not.
It is just a whole lot less repeatable if we do.

I think the issue is more whether the program takes a hit on speed judging by Bots little test program.
Title: Regarding the seed value function!
Post by: PurpleYouko on June 29, 2005, 08:57:34 PM
Quote
Pinball heh I thought that was a vedio game , I could not figure out how to control anything exsept the start button, and delay.
Quote
So you just don't need to reseed it more than once. If you can find something to the contrary, I'll of course change my opinions, but I'm fairly certain reseeding the random function continuously actually decreases it's statistical randomness ( a wierd thing, I know).

Pinball in the original penny arcade was a vertical slot into which you dropped a token or a penny. It would bounce around the pins and statistically would land close to the centre.
Certain channels would give prizes just like a slot machine.
Other versions of the game would have sliding shelves covered in coins that could be knocked off into the collection tray.

You still see newer versions of them now.

There are no controls. You put the coin in and that's it.
On my excel game, the delay control just slows down the graphical display.
Title: Regarding the seed value function!
Post by: Greven on June 30, 2005, 05:26:55 AM
I dont know how many random calls there is in DB, but even if there is a sequence, it doesnt matter, there are so many different variables to take into account and therefore DB will not repeat it self inside the same simulation.

The reseeding function does slow down the program alot, but I dont know have much, but if we could get 25% or more in speed, it could matter alot, to only reseed the function once, and what I have advocated before, that it will be much easier to find the small overflow errors etc., for you programmers.

Think about it. A user get an error. He (or she) check that the seed value is 5346.5 (or some other stupid number) and the error occured in the 54.459 cycle. The user writes a bugreport on this, you check it in VB, and finds the error! THIS WILL MAKE POSSIBLE BUGREPORTING MUCH EASIER. Forget the old days when a bug is reported and non other are able to reproduce the extract same bug/error etc.

Halleluja for a DB without strange errors!  :D
Title: Regarding the seed value function!
Post by: PurpleYouko on June 30, 2005, 11:01:00 AM
Currently (2.37.2) the seed is randomized on every cycle.
I don't think removing it would make a huge difference to the run speed since there is such a lot of stuff happening per cycle. In Bots little program the cycle rate is thousands per second because it is so short. removing the reseed function there makes a big difference but probably not in DB. Still every little bit counts.

There aren't vbery many random call really in DB. They only happen when seeding or reseeding robots (for X Y coordinates), during repro for mutations and when a robot's DNA call the rnd function.

Other than that DB is completely deterministic.
Title: Regarding the seed value function!
Post by: Botsareus on June 30, 2005, 03:38:10 PM
PY, I know I maid it a little scroovy. Thats probebly were you got confused.

  If you click the top most button , and then right after it click the middle button the only thing you really notice is a difference in speed.
   But If after clicking the top most button you click "stop / reset" a couple of times, then click the middle button you should see indeed "a flower thingy" witch is a little waird but proves nums point. You can also get the same result if the middle button is the first button you click.

P.S.

I really should start thinking about making my stuff more user frandly.
Title: Regarding the seed value function!
Post by: Numsgil on June 30, 2005, 05:53:58 PM
Scroovy.   :wacko:

A Bunch of Thing Scroovy Quares.
Title: Regarding the seed value function!
Post by: Botsareus on June 30, 2005, 07:37:24 PM
GG with that , I am at 800 kills right now , dont have time to reply to nonsence.
Title: Regarding the seed value function!
Post by: PurpleYouko on July 01, 2005, 09:00:30 AM
As if it wasn't hard enough to become a Quare in the first place, now I have to thing even harder so I can be scroovy too.

Rock on all you Scroovy Quares. Keep on thinging! :Headbang:
Title: Regarding the seed value function!
Post by: PurpleYouko on July 01, 2005, 09:02:24 AM
Quote
PY, I know I maid it a little scroovy. Thats probebly were you got confused.

  If you click the top most button , and then right after it click the middle button the only thing you really notice is a difference in speed.
   But If after clicking the top most button you click "stop / reset" a couple of times, then click the middle button you should see indeed "a flower thingy" witch is a little waird but proves nums point. You can also get the same result if the middle button is the first button you click.

P.S.

I really should start thinking about making my stuff more user frandly.
I tried all that but I just saw random dots with no pattern. Maybe I didn't leave it going long enough.
Title: Regarding the seed value function!
Post by: Botsareus on July 01, 2005, 12:03:52 PM
Anyway what you were supposed to see is for a  short ammount of time the one with reseed should form stuff like this:

(http://img207.imageshack.us/img207/4607/untitled1af.gif) (http://www.imageshack.us)

With the points turning red really quickly , witch is not supposed to happen.
Title: Regarding the seed value function!
Post by: PurpleYouko on July 01, 2005, 12:46:58 PM
Still can't even open the thing from this PC. Clicking your link just opens an HTML text file.  :blink:
Even pasting it into VB doesn't work. There are so many errors that it would be quicker to rewrite a new program.

Very scroovy indeed!