Package jason.stdlib

Class random

java.lang.Object
All Implemented Interfaces:
InternalAction, java.io.Serializable

@Manual(literal=".random(value)",
        hint="generates a random number between 0 and 1",
        argsHint="the variable to receive the random value",
        argsType="number",
        examples={".random(X): unifies X with one random number between 0 and 1",".random(X, 5): unifies X with a random number between 0 and 1, and backtracks 5 times. For example: .findall(X, .random(X,5), L) will produce a list of 5 random numbers",".random(X, 0): unifies X with a random number between 0 and 1, and backtracks infinitely"},
        seeAlso="jason.functions.Random")
public class random
extends DefaultInternalAction

Internal action: .random(N).

Description: unifies N with a random number between 0 and 1.

Parameter:

  • + options> (list, optional): the list of possible values, default values are any real number
  • - value (number): the variable that unifies with a random value from options
  • + quantity of random values (number, optional): default value is 1, value = 0 means that an infinity number of random values will be produced (this is useful for some backtrack circumstances).

Example:

  • .random(X): unifies X with one random number between 0 and 1.
  • .random(X, 5): unifies X with a random number between 0 and 1, and backtracks 5 times. For example: .findall(X, .random(X,5), L) will produce a list of 5 random numbers.
  • .random(X, 0): unifies X with a random number between 0 and 1, and backtracks infinitely.
  • .random([a,b,c],X): unifies X with a random value from a, b, or c.
See Also:
function version, Serialized Form