Jump to Navigation

Conditional Events


Seeing story elements as decomposition of a story into actions and events, the use of conditions and effects is inevitable to give these actions/events a meaning. In the following we will show different concepts and examples from a range of tools.
But at first we will give an overview of what conditions and effects are and which other concepts need to be understood to use them.

Conditions

In general a condition defines under which circumstances an action/event can be performed. For example it is only possible to open a door if the door is unlocked. If that door is part of an interactive story in which the user has to get from one room into another to proceed, authors have to define a condition if they want that door to be an obstacle, for example if the player has first to find a key that unlocks it.

So what has the system now to do if the user tries to walk from the corridor into the bedroom? At first it has to check if the door is already opened, or more formal:

ACTION: 
User_tries_to_get_from_corridor_into_bedroom_by_using_the_door

CONDITION: 
IF ( DOOR_open == true ) THEN 
      ACTION: 
            User_walks_from_corridor_into_bedroom_by_using_the_door
ELSE
      ACTION: 
            System_tells_user_that_door_is_closed

This condition depends on the current state of the world in which the user tries to walk trough the door. Or to be more concrete, it depends on the state of the door, is it open or not? In our case this state is described by the variable DOOR_open that can be true or false - true meaning that the door already is open. So a condition should cover all possible states that could be important in a certain situation of the story. In our case that is very simple, because we only have the door that could be opened or closed and that is covered by our condition. We could also have described it in a different way:

ACTION: 
User_tries_to_get_from_corridor_into_bedroom_by_using_the_door

CONDITION: 
IF ( DOOR_open == true ) THEN 
      ACTION: 
            User_walks_from_corridor_into_bedroom_by_using_the_door
ELSE 
      IF ( DOOR_open == false ) THEN
            ACTION: 
                  System_tells_user_that_door_is_closed
      ELSE
            ACTION: 
                  System_Error

This example covers explicitly both possible states of the door. Because the variable can only have the two states/values true or false the last action (System_Error) will never be performed.
Taking a closer look at the condition we find that it consists of three main elements:

  • Variable
  • Relational operator
  • Value

A variable is a value that may change within the scope of a set of operations or a given problem. It can be seen as a kind of container with a name written on it and in which you can put one concrete value at a time. But you can also take it out and put a different one inside. But you also have to take care of the type of the variable because not all types of values fit into the same container. For example the container of the variable Natural_Numbers (or Integer in computer science) may contain the value 1, 2 or 3, but not the value “greenâ€.

In our example above the variable is named Door_open and is of the type Boolean, that means its only valid values are true and false (or 1 and 0).

The most common relational operators are:

  • equal to (==)
  • not equal to (!=)
  • greater than (>)
  • less than (<)
  • greater than or equal to (>=)
  • less than or equal to (<=)

They are used to compare the current value of a variable with a predefined value. The result is the statement that the expression (the condition) as a whole is true or false. If the expression is true, the following action will be performed. If not, the system looks for the next condition(s) until the ELSE statement is reached and the there defined action is performed.

It is also possible to combine single conditions into more complex ones. Therefore the logical (or Boolean) operators AND and OR are used. If two (or more) conditional expressions are connected by an AND, both (all) of them have to be true to make the whole expression true. If they are connected by an OR, a minimum of one expression has to be true to make the whole true.

Effects

Effects may have different manifestations in the field of Interactive Digital Storytelling. A simple one is an arithmetical. That means an effect is the modification on an numerical variable by adding (+), subtracting (-), multiplying (*) or dividing (/) it with another numerical variable or value. The result of a modification of values is normally assigned to a certain variable which is symbolised by ":=".

For example:

  1. DOOR_open := true
  2. MOOD := MOOD - 1
  3. MOOD := ANGER + HAPPINESS

The first example means, that the new value of the variable DOOR_open is now true. The second example means that the current MOOD is lowered my 1 and the third that the mood is the sum of the current values of the variables ANGER and HAPPINESS.

In the following examples of conditional events of selected systems are presented.




by Dr. Radut.