quinta-feira, 12 de maio de 2016

BP Compendium 2: Relational and Logical Operators

Relational and Logical Operators

The relational operators perform a comparison between two values ​​and return a Boolean value (true or false) as a result of the comparison. The relational operators are as follows:

Click to enlarge

The example below shows the use of a relational operator and a "Branch". At the end of a game will be compared the current player's score (Score variable) with the highest game score (High Score variable). If the player's score is higher, the value of the "Score" variable will be stored in the "High Score" variable.

Click to enlarge

Logical operators perform an operation between boolean values ​​and return a boolean value (true or false) as a result of the operation. The main logical operators are:

The logical OR operator returns "true" if any of the input values ​​are "true". The logical AND operator returns "true" only if all inputs are "true". The logical NOT operator receives only one input value and the result will be the reverse value.

The following example simulates a simple decision of an Enemy in a game. If the Enemy is low on ammo (LowAmmunition variable) and the player is nearby (PlayerIsNear variable) then the Enemy decides to run away.

Click to enlarge

Table of Contents