Bug: Weird random pattern!
I was trying to make MMF2 draw me a random pattern, and then I discovered a weird bug. The pattern it makes is identical on each side, very much like a mirror. And after a while of drawing it just stops, even though I haven't told it to.
To reproduce:
Make a single active object, resize to 1 pixel in size. And add this event...
+ Always
- Set X Position to ("Active") + random(2) - random (2)
- Set Y Position to ("Active") + random(2) - random (2)
- ("Active"): Add backdrop
Copy this event 40-50 times so it doesn't take too long to draw the pattern. Run Application and watch the pattern.
Example file here
[edit: I was wrong, it does not stop! In fact it just moves in the same pattern all over again! Why does it do that?]
Re: Bug: Weird random pattern!
You're not seeing anything more being drawn because the bank of randomly generated numbers has looped around back to the beginning and the object is drawing over the top of itself again. If you run it a few times, occasionally you'll see the pattern slowly moving across the screen as the same random numbers are used again.
It's not so much a bug as due to the way that computers generate random numbers. To get a more 'random' pattern, you need something to generate random numbers from - for example, use a Date and Time object in the frame, and Randomize (under "Special") with the value of its seconds every time a second passes.
Re: Bug: Weird random pattern!
As davidN said, it's not a bug. Add an event such as
-Always Randomize timer
and you'll get something better. Timer always increases, that's why it will work, if you used Randomize "Hundreds" or "seconds" or something like that you'll get a pattern again (every 1 second or 60 sec).
Re: Bug: Weird random pattern!
I see, I never saw random numbers that way before. But now it doesn't feel very much like "random" values anymore... :P
The work-around works like a charm, even though I don't really understand how it works.
When I for example use random(100) inside the randomize action instead of "seconds of ("Date & Time") the pattern goes odd again. How come it only works using seconds as value? :S
Re: Bug: Weird random pattern!
Quote:
I see, I never saw random numbers that way before. But now it doesn't feel very much like "random" values anymore... :P
If you think about it, how is a computer supposed to generate a truly random number, when everything that happens inside it are mathematical calculations? It's logically impossible to program something that just picks a random number out of thin air.
To explain how this process works: There's always a "random seed" involved - a number which is used to mathematically calculate a series of other numbers which purpose is to appear as random as possible. The same random seed will always generate the same series of numbers.
Try this. Create a new empty application, and add a counter. In the event editor, you use these events:
[Start of frame]
(Special Conditions) Randomize 1
[Upon pressing Space Bar]
Set counter to random(10)
Now launch your application, and press Space Bar to see it generate random numbers. Then close the application and start it again. Press Space Bar a few times to see it generate exactly the same series of numbers (4-4-7-0-2-5-9 and so on), since it "1" is it's random seed.
To get a series of numbers that's different every time, you basically need to get the random seed from something that's not a constant. You usually use the internal computer clock, but you can also use the mouse position, etc.
How random the pattern will appear depends on two things.
1: How is the random number algorithm programmed?
2: What is the random seed, and how often is it changed?
Re: Bug: Weird random pattern!
I think people use the word bug to freely also. I say if you haven't used MMF for more than a few years don't post a bug thread...
Just because something isn't understood, does not categorize it as a bug. :sleep:
Re: Bug: Weird random pattern!
Nifflas: Thanks for the explaination. Made me a bunch smarter. :-)
OOJ: I've used click tools back to 1997 starting with Klik 'n Play. It's almost 10 years exactly now. So just because you use them for years doesn't mean you know exactly how they function. Also it's better to be safe than sorry. :P
Re: Bug: Weird random pattern!
I wasn't saying asking for help was a problem, just that people in general use the word bug too much to describe a problem they have, the way I understand the meaning of the word bug, "programming error". Anyhow, it's not a big deal. I didn't offer a solution so my post wasn't really constructive anyway.