RAIN.Belief.Expression Class Reference

Expression is used to represent math calculations that can be evaluated into float numbers. Expressions are usually entered as text representations similar to Java or C# expressions. Expressions may be nested and may contain variables. The variable "t" always represents time, and is always bound to deltaTime during expression evaluation. Expressions are used throughout RAIN in Goal Oriented Behavior and Behavior Trees. More...

## Public Types | |

enum | OperatorType |

OperatorType represents standard math operators include addition, subtraction, multiplication, and division Support is not currently included for mod or remainder operations. More... | |

## Public Member Functions | |

Expression () | |

Default constructor. Initializes to an empty invalid NO_OP expression. | |

void | Clear () |

Clear any nested expressions and reset state to an empty invalid NO_OP. | |

void | RenameVariable (string originalName, string newName) |

Rename a variable in this and all nested expressions. | |

void | SetConstant (float k) |

Set the expression to represent a constant value. This expression will always evaluate to the constant. | |

void | SetVariable (string variable) |

Set the expression to represent a variable value. Only a single variable name will be entered. The variable is not checked against the existing variable context, but is just assumed to be bound at runtime. A variable name may be any string, although using non standard (Java/C#) variable names will result in expressions that can't be rewritten and reparsed. | |

void | SetTimeExpression () |

Set the expression to represent time. This expression will evaluate to the deltaTime value passed into the Evaluate method. | |

void | SetInvalid () |

Invalidate the Expression. Evaluation will return NaN (not a number) for invalid Expressions. | |

void | SetExpression (Expression expr1, OperatorType operatorType, Expression expr2, bool isAtomic) |

SetExpression will directly set a complex expression as a left-hand-side (lhs, an infix operator, and a right-hand-side (rhs). isAtomic is used to mark the expression so that its terms do not get reordered on subsequent calls to FixOperatorPrecedence. This is equivalent to adding parenthesis around the expression. | |

float | Evaluate (float deltaTime, ActionContext actionContext) |

Evaluate calculates the value of the value of this expression as a float. | |

float | Evaluate (float deltaTime, float minValue, float maxValue, ActionContext actionContext) |

Evaluate calculates the value of the value of this expression as a float. | |

followed by a term with a lower precedence the expression tree may be rearranged *</summary > *void | FixOperatorPrecedence () |

void | SetAtomic (bool isAtomic) |

SetAtomic marks an expression so that it can't be changed by the FixOperatorPrecedence function. This is the equivalent of surrounding the expression with parenthesis. | |

override string | ToString () |

ToString() will return a string representation of the Expression which may differ from the original text parsed to create this expression. | |

## Properties | |

bool | IsConstant` [get]` |

Does the expression represent a constant? | |

bool | IsVariable` [get]` |

Does the expression represent a variable? | |

bool | IsComplex` [get]` |

Does the expression represent a complex expression? | |

bool | IsTime` [get]` |

Does the expression represent delta time (t)? | |

bool | IsValid` [get]` |

Is the expression valid and can it be evaluated successfully? | |

string | VariableName` [get]` |

If the expression represents a variable, returns the variable name Returns null otherwise. | |

string | ExpressionAsEntered` [get, set]` |

ExpressionAsEntered returns the text used to initially describe the Expression, if the expression was created from parsing a script or manual entry. This is useful when supporting user editing of invalid expressions. |

Expression is used to represent math calculations that can be evaluated into float numbers. Expressions are usually entered as text representations similar to Java or C# expressions. Expressions may be nested and may contain variables. The variable "t" always represents time, and is always bound to deltaTime during expression evaluation. Expressions are used throughout RAIN in Goal Oriented Behavior and Behavior Trees.

OperatorType represents standard math operators include addition, subtraction, multiplication, and division Support is not currently included for mod or remainder operations.

Default constructor. Initializes to an empty invalid NO_OP expression.

void RAIN.Belief.Expression.Clear | ( | ) |

Clear any nested expressions and reset state to an empty invalid NO_OP.

float RAIN.Belief.Expression.Evaluate | ( | float | deltaTime, |

ActionContext | actionContext |
||

) |

Evaluate calculates the value of the value of this expression as a float.

**Parameters:**-
deltaTime time to use for expressions utilizing the variable "t" actionContext ActionContext to use for variable expressions

- Returns:

float RAIN.Belief.Expression.Evaluate | ( | float | deltaTime, |

float | minValue, |
||

float | maxValue, |
||

ActionContext | actionContext |
||

) |

Evaluate calculates the value of the value of this expression as a float.

**Parameters:**-
deltaTime time to use for expressions utilizing the variable "t" actionContext ActionContext to use for variable expressions

- Returns:

void RAIN.Belief.Expression.RenameVariable | ( | string | originalName, |

string | newName |
||

) |

Rename a variable in this and all nested expressions.

**Parameters:**-
originalName The name of the variable to rename newName The new name to replace the original variable name

void RAIN.Belief.Expression.SetAtomic | ( | bool | isAtomic | ) |

SetAtomic marks an expression so that it can't be changed by the FixOperatorPrecedence function. This is the equivalent of surrounding the expression with parenthesis.

**Parameters:**-
isAtomic

void RAIN.Belief.Expression.SetConstant | ( | float | k | ) |

Set the expression to represent a constant value. This expression will always evaluate to the constant.

**Parameters:**-
k The constant value to use

void RAIN.Belief.Expression.SetExpression | ( | Expression | expr1, |

OperatorType | operatorType, |
||

Expression | expr2, |
||

bool | isAtomic |
||

) |

SetExpression will directly set a complex expression as a left-hand-side (lhs, an infix operator, and a right-hand-side (rhs). isAtomic is used to mark the expression so that its terms do not get reordered on subsequent calls to FixOperatorPrecedence. This is equivalent to adding parenthesis around the expression.

**Parameters:**-
expr1 The lhs expression operatorType Mathematical operator expr2 The rhs expression isAtomic A value indicating whether FixOperatorPrecedence can reorder terms.

void RAIN.Belief.Expression.SetInvalid | ( | ) |

Invalidate the Expression. Evaluation will return NaN (not a number) for invalid Expressions.

Set the expression to represent time. This expression will evaluate to the deltaTime value passed into the Evaluate method.

void RAIN.Belief.Expression.SetVariable | ( | string | variable | ) |

Set the expression to represent a variable value. Only a single variable name will be entered. The variable is not checked against the existing variable context, but is just assumed to be bound at runtime. A variable name may be any string, although using non standard (Java/C#) variable names will result in expressions that can't be rewritten and reparsed.

**Parameters:**-
variable A variable name to use when binding at runtime. Variable names are case sensitive.

override string RAIN.Belief.Expression.ToString | ( | ) |

ToString() will return a string representation of the Expression which may differ from the original text parsed to create this expression.

- Returns:
- Returns a text representation of the Expressoin

string RAIN.Belief.Expression.ExpressionAsEntered` [get, set]` |

ExpressionAsEntered returns the text used to initially describe the Expression, if the expression was created from parsing a script or manual entry. This is useful when supporting user editing of invalid expressions.

bool RAIN.Belief.Expression.IsComplex` [get]` |

Does the expression represent a complex expression?

bool RAIN.Belief.Expression.IsConstant` [get]` |

Does the expression represent a constant?

bool RAIN.Belief.Expression.IsTime` [get]` |

Does the expression represent delta time (t)?

bool RAIN.Belief.Expression.IsValid` [get]` |

Is the expression valid and can it be evaluated successfully?

bool RAIN.Belief.Expression.IsVariable` [get]` |

Does the expression represent a variable?

string RAIN.Belief.Expression.VariableName` [get]` |

If the expression represents a variable, returns the variable name Returns null otherwise.

Generated on Mon Aug 13 2012 10:37:40 by 1.8.0