math.random

Suggest changes and improvements to Algodoo.

math.random

Postby mold999 » Wed Apr 20, 2011 1:03 am

I know this might have been suggested before, but I looked up "math.random" and "random number" and other various crap and got nothing.

There should be a math.random function in the script. So if I wanted a number between 1 and ten, I'd type:

Code: Select all
math.random(1, 10)


(I must thank TC42 for this... He was the one who first came up with the math.random(min, max).)
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: math.random

Postby TC42 » Wed Apr 20, 2011 1:12 am

Nope, actually that was Kilinich or Grady, I think.
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: math.random

Postby mold999 » Wed Apr 20, 2011 1:15 am

Oops...

I'm sorry.
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: math.random

Postby Sonic » Wed Apr 20, 2011 1:34 am

I support. We've needed this for a while now.
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: math.random

Postby Someone Else » Wed Apr 20, 2011 6:30 pm

Hmm... Last time I remember math.random being suggested, I suggested it. That was, however, yesterday. And on a scene.my.random topic of TC42's.

I would also suggest a math.randGauss function- it would pick a number with Gaussian distribution.
The graph of a Gaussian function is better known to some as a bell curve.

I still support anyway.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: math.random

Postby Sonic » Wed Apr 20, 2011 8:59 pm

How would a Gaussian division help it?
I do stuff and break things. You know how it is.
Image
User avatar
Sonic
 
Posts: 1467
Joined: Tue Sep 01, 2009 6:18 pm
Location: America!!!

Re: math.random

Postby Rrobba » Fri Apr 22, 2011 12:28 am

support
Image
I don't suffer from insanity. I enjoy every minute of it.
User avatar
Rrobba
[Best Sig 2010]
 
Posts: 1480
Joined: Mon Aug 31, 2009 6:01 pm
Location: Gibraltar

Re: math.random

Postby Someone Else » Fri Apr 22, 2011 2:43 am

Sonic wrote:How would a Gaussian division help it?

Who cares?
Somebody'd use it, right?
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: math.random

Postby tatt61880 » Fri Jun 17, 2011 2:10 pm

Support. But I don't think 2 arguments are best for random. ;)
NOTE: I'm not an Algoryx member.
Hi, Algodoo lovers. Have you read next topic? Featured scenes suggestions
To translators: English.cfg changelog will be useful (even for me).
User avatar
tatt61880
[Most Helpful Person 2010]
 
Posts: 1150
Joined: Mon Aug 31, 2009 5:45 pm
Location: Tokyo, Japan

Re: math.random

Postby mold999 » Sat Jun 18, 2011 9:47 pm

tatt61880 wrote:Support. But I don't think 2 arguments are best for random. ;)


So long as there aren't any arguments against it, I think it should be seriously considered.
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: math.random

Postby Chronos » Sat Jun 18, 2011 10:54 pm

I would disagree, Tatt. Two arguments (one for minimum value, the other for maximum value) would work perfectly.
TheWinkits wrote:They both looks of cuking amazing
User avatar
Chronos
[Most Active Member 2010]
 
Posts: 4457
Joined: Mon Aug 31, 2009 6:00 pm
Location: Californania

Re: math.random

Postby KarateBrot » Mon Jul 25, 2011 2:01 pm

TC42 wrote:Nope, actually that was Kilinich or Grady, I think.

it was me if i remember correctly (the first one without just using periodic trigonometric functions or the color values of spawning objects). it has of course two parameters: "min" and "max"
it was always here for 1.5 years.

but kilinich made a neat and short function half a year ago which is way cooler in my opinion.
it's right here

i was inactive for over a year so please tell me if i missed anything important. but i've already noticed that there are a lot of actual scripting problems which were already solved over 1 or 2 years ago.
having said this: use the search bar peepz :D
Image
User avatar
KarateBrot
 
Posts: 825
Joined: Mon Aug 31, 2009 7:32 pm
Location: Germany

Re: math.random

Postby electronicboy » Mon Jul 25, 2011 2:14 pm

welcome back, i suppose...

i kinda have a suggestion for this:

Code: Select all
math.random( min, max, range)

range would let you select weather you want  a whole number
e.g. 1
or if you want a decimal
e.g. 0.001 (would give you a number upto an accuracy of (0.001     e.g. 0.009 or 2.211)

so,
math.random(1, 2, 0.05),
could give a number such as, 1.55


just a suggestion....
When asking for help, READ THE STICKIES!
electronicboy
 
Posts: 1694
Joined: Mon Aug 31, 2009 6:18 pm

Re: math.random

Postby mold999 » Mon Jul 25, 2011 7:51 pm

I suppose that would help...
Phundementalism?

Ain't nobody got
thyme fo dat.
User avatar
mold999
 
Posts: 225
Joined: Sun Jan 02, 2011 1:35 am
Location: [176436, 3763234]

Re: math.random

Postby Gear97 » Mon Jul 25, 2011 9:07 pm

Well, I TOTTALY SUPPORT THIS ! I was going to make a scene needed this and this would be useful for many other things and if I am not wrong it should enable us to make genetic algorithms more easily. :thumbup:
Gears are my favorite mechanism. Why do you think I have this username ? ;)
Make sure to spend some time to see my work http://www.algodoo.com/algobox/profile.php?id=96, just to kill sometime ;)
PS: Gear97™ Is a trademark from me. Any unauthorized use of the term "Gear" for usernames or other naming ideas will be punished.
User avatar
Gear97
 
Posts: 146
Joined: Sat Jan 02, 2010 5:34 pm
Location: Brazil

Re: math.random

Postby Someone Else » Tue Jul 26, 2011 5:17 am

Yes, I actually have my own version... And I fully support full integration.

Here's my version:
Code: Select all
scene.my.random1 = (min, max, step)=>{
    N = (((scene.addCircle({
        collideSet := 0;
        airFrictionMult = -inf;
        pos := [+inf, +inf]
    })).color(0)) * (max - min)) + min;
    {step != 0} ? {N - math.mod(N, step)} : {N}
}

I must now say that I really like the idea of having three arguments- minimum value, maximum value, and the step.

Note that the "step" argument doesn't quite work properly. It will spit out a number that is a multiple of the step, not a multiple of step, then added to min...

Note that math.mod with 0 as the second argument will spit out NaN. Hence the IF.

Relevance Factor of 0.1: We really do have elseIf structures at our disposal!
{false} ? {1} : {false} ? {2} : {true} ? {3} : {4} = 3
TC42, I'm amazed at how you pulled the correct syntax out of thin air!

Back on topic:
Code: Select all
scene.my.random2 = (min, max, step)=>{
    N = ((scene.addCircle({
        collideSet := 0;
        airFrictionMult = -inf;
        pos := [+inf, +inf]
    })).color(0)) * (max - min);
    {step != 0} ? {N - math.mod(N + (step * 0.1), step)} : {N} + min
}

Doesn't work too well, but at least it does work. It will produce a value as described above, but not very precicely. Also, if you set it up to produce one of three values (i.e. scene.my.random2(0, 1, 0.5)), it will almost always produce the middle value.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: math.random

Postby Mag8328 » Thu Aug 04, 2011 9:18 pm

Support! Might come in handy :thumbup:
The Simulation of Everything
I dream of a massive collab to make an accurate simulator of the evolution of space (id=56341), evolution of beings (id=56522), and chemicals (id=43179), etc. all wrapped into one.
User avatar
Mag8328
 
Posts: 16
Joined: Wed Jun 22, 2011 12:40 am

Re: math.random

Postby willy101 » Fri Aug 12, 2011 7:51 pm

Total Support :D
Heres My Sig :) :

UNDER CONSTRUCTION :( UNDER CONSTRUCTION :( UNDER CONSTRUCTION :( UNDER CONSTRUCTION :( UNDER CONSTRUCTION.......
User avatar
willy101
 
Posts: 6
Joined: Sat Aug 06, 2011 5:02 pm
Location: Somewhere..DUH!!

Re: math.random

Postby Kutis 96 » Fri Aug 19, 2011 4:57 pm

Support, coz i fu***ng need this! :)

no, rly
I'm back! (not really!)

I'm also making real hardware, sometimes.
User avatar
Kutis 96
 
Posts: 107
Joined: Mon Jun 28, 2010 7:49 pm
Location: Chasing red dots.


Return to Suggestions

Who is online

Users browsing this forum: No registered users and 2 guests