Package jason.stdlib
Class random
java.lang.Object
jason.asSemantics.DefaultInternalAction
jason.stdlib.random
- All Implemented Interfaces:
InternalAction
,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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkArguments
(Term[] args) execute
(TransitionSystem ts, Unifier un, Term[] args) Executes the internal action.int
int
Methods inherited from class jason.asSemantics.DefaultInternalAction
canBeUsedInContext, destroy, prepareArguments, suspendIntention
-
Constructor Details
-
random
public random()
-
-
Method Details
-
getRandomGenerator
-
getMinArgs
public int getMinArgs()- Overrides:
getMinArgs
in classDefaultInternalAction
-
getMaxArgs
public int getMaxArgs()- Overrides:
getMaxArgs
in classDefaultInternalAction
-
checkArguments
- Overrides:
checkArguments
in classDefaultInternalAction
- Throws:
JasonException
-
execute
Description copied from interface:InternalAction
Executes the internal action. It should return a Boolean or an Iterator. A true boolean return means that the IA was successfully executed. An Iterator result means that there is more than one answer for this IA (e.g. see member internal action). - Specified by:
execute
in interfaceInternalAction
- Overrides:
execute
in classDefaultInternalAction
- Throws:
Exception
-