Random number generator in Thyme

About advanced scenes, and the Thyme scripting language used in Algodoo.

Random number generator in Thyme

Postby hpstricker » Wed Jan 24, 2018 1:38 pm

Is there a way to generate random numbers in Thyme?
hpstricker
 
Posts: 16
Joined: Wed Jan 03, 2018 11:10 am

Re: Random number generator in Thyme

Postby Kilinich » Fri Jan 26, 2018 9:52 pm

rand.boolean
rand.direction2D
rand.normal
rand.normal2D
rand.uniform01
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Random number generator in Thyme

Postby HumanoidX » Mon Jun 29, 2020 12:04 pm

I am really sorry for bumping this post, I know nobody likes bumping post, but can someone please explain how these five functions work?
onCollide:
(e)=>{
System.exit;
}
HumanoidX
 
Posts: 3
Joined: Tue Jun 23, 2020 10:39 am

Re: Random number generator in Thyme

Postby FRA32 » Sat Jul 18, 2020 10:07 pm

Rand.uniform01 generates a random number between 0 and 1. You can manipulate the result to create any number range you want such as:

Rand.uniform01*10-5 for all numbers from -5 to +5

Rand.normal generates numbers in a normal distribution, i.e as if you were throwing darts at a target. Near the center (zero) the propability is the highest, the further away you go (positive and negative direction), the lower it drops(at roughly 6 its low enough to be assumed zero chance)

Rand.normal2D is rand.normal but this in 2D coordinates around [0,0]

rand.boolean is a random yes/no result

Rand.direction2D results in a vector (a [x,y] number] that's always a random point on a circle with radius one around [0,0]
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm

Re: Random number generator in Thyme

Postby HumanoidX » Sat Jul 25, 2020 10:32 am

Oh yeah, thanks for replying, that's enlightening. I thought that this forum is no longer active. Thanks! :P :lol: :D :) :clap: :mrgreen:
onCollide:
(e)=>{
System.exit;
}
HumanoidX
 
Posts: 3
Joined: Tue Jun 23, 2020 10:39 am


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 2 guests