**About the Random Library**
The

*Random* library can be used to generate

*random* numbers (

*ints* and

*floats*).

These numbers are actually

*pseudo-random*, which means they are a predictable sequence of numbers starting from a

*hard to predict* number. This means it's usually

*random enough* for most purposes.

The library provides procedures to generate random numbers

*in a certain inclusive range* (meaning the numbers you specify might show up).

This library is entirely contained in the

Game Engine library (just like print is inside IO).

**How to Use It**
It's as simple as

*importing* the Random library:

And then calling its procedures whenever you want. For example:

#import

"Random"

main

:: () {

random_int :=

random_int_in_range

(

0

,

10

);

random_float :=

random_float_in_range

(

-1

,

1

);

}

To see the

*randomness* of the numbers you can

*import* the

Print library and print some of the generated numbers:

#import

"IO"

#import

"Random"

main

:: () {

for

0

..

10

{

print_float

(

random_float_in_range

(

-1

,

1

));

print

(

"\n"

);

}

}

**Complete API**
### random_int_in_range

This is the

*declaration* of the

*random_int_in_range* procedure:

random_int_in_range

:: (min_inclusive :=

0

, max_inclusive :=

10

) -> random_value :

int

{

This procedure generates and returns a random

integer number between the specified

*range*.

The range is

*inclusive*, which means the minimum and maximum numbers can show up in random result.

#import

"Random"

main

:: () {

random :=

random_int_in_range

(

0

,

10

);

}

### random_float_in_range

This is the

*declaration* of the

*random_float_in_range* procedure:

random_float_in_range

:: (min_inclusive :=

0.0

, max_inclusive :=

1.0

) -> random_value :

float

{

This procedure generates and returns a random

float number between the specified

*range*.

The range is

*inclusive*, which means the minimum and maximum numbers can show up in random result.

It works just like the

*random_int_in_range* procedure.

#import

"Random"

main

:: () {

random :=

random_float_in_range

(

-10.0

,

10.0

);

}