Proper random number generation and radian/degree.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
MHD
Prole
Posts: 18
Joined: Fri Nov 14, 2008 11:45 pm
Location: Denmark

Proper random number generation and radian/degree.

Post by MHD »

I have noticed that Löve uses the default pseudo-random number generator. I suggest that you in the next versions implement a proper random generation (avilable somewhere on lua.org). Also I suggest that you take a stand point and decide to either convert all Löve functions to radians or all lua functions to degrees (this can be done at loadup manually, but...).
I r awsum at looah ^^
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Proper random number generation and radian/degree.

Post by rude »

Well, you are quite the suggestionist[1], aren't you? ;)

You must have an average of two-three suggestions per day or something. :D

[1] Probably not a word.
u9_
Citizen
Posts: 54
Joined: Thu Oct 23, 2008 7:12 am

Re: Proper random number generation and radian/degree.

Post by u9_ »

I think we brought up the degrees-vs-radians in another thread. One thing that kinda bugs me is rotations seem to be clock wise for increasing degrees. For a mathematician this is a little "upside-down", but it's easily solvable with a - in front :)

I would like to know what is the difference with the "proper" random generator and the pseudo random generator... specifically, when is it not a pseudo random generator. Afaik, there exist only pseudo random generators on computers, because they are deterministic.
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

Re: Proper random number generation and radian/degree.

Post by subrime »

I think the conventional understanding is that a pseudo-random function will use a deterministic function to supply the same sequence of pseudo-random numbers every time it is reset, while a (non pseudo) random function will use a deterministic function with a changing seed (such as the current system time) to supply a different sequence of pseudo-random numbers each time it is reset.

As for radian and degrees, I think it unwise to change the behaviour of the standard lua math functions as people already accustomed to coding with lua/c/any-decent-language could easily be caught off guard.
User avatar
tido
Prole
Posts: 28
Joined: Mon Feb 04, 2008 4:08 pm
Contact:

Re: Proper random number generation and radian/degree.

Post by tido »

May I humbly suggest that we implement the multiply-with-carry pseudo-random number generator? According to G. Marsaglia, it is better than Mersenne twister (current favorite) because it's fast AND provides better period. You can read about it here: http://en.wikipedia.org/wiki/Multiply-with-carry
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: Proper random number generation and radian/degree.

Post by mike »

I think the nerd factor of this forum just spiked. Discussing the random number generator we should use. That's pretty hardcore.
Now posting IN STEREO (where available)
u9_
Citizen
Posts: 54
Joined: Thu Oct 23, 2008 7:12 am

Re: Proper random number generation and radian/degree.

Post by u9_ »

subrime wrote:I think the conventional understanding is that a pseudo-random function will use a deterministic function to supply the same sequence of pseudo-random numbers every time it is reset, while a (non pseudo) random function will use a deterministic function with a changing seed (such as the current system time) to supply a different sequence of pseudo-random numbers each time it is reset.
So we just need to add math.randomseed( os.time() ) at the beginning of each program?
mike wrote:I think the nerd factor of this forum just spiked. Discussing the random number generator we should use. That's pretty hardcore.
I concur!
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Proper random number generation and radian/degree.

Post by rude »

Lua will remain 100% standard and will not be changed. We'll have to change LÖVE if we want to change anything.
User avatar
subrime
Citizen
Posts: 76
Joined: Thu Nov 13, 2008 6:18 pm
Location: Australia

Re: Proper random number generation and radian/degree.

Post by subrime »

u9_ wrote: So we just need to add math.randomseed( os.time() ) at the beginning of each program?
Yes, that's the idea.
surtic
Citizen
Posts: 74
Joined: Sat Jul 12, 2008 12:18 am

Re: Proper random number generation and radian/degree.

Post by surtic »

Just a quick note - Lua's random number generator has problems with the first few numbers.

I suggest using

Code: Select all

math.random()
math.random()
math.random()
at the beginning of a program to get rid of these "bad" values.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests