COALA Back-end

Contexts

Overview

The Contexts tab is arguably the most important area in the Back-end as this is where you can define all the real-world contexts that you wish to appear or affect your world or app. Defining a context is technically defining an area. For example, if your app has a map, you need to define in this tab all the different terrain types you wish to be generated, such as parks, water bodies, Places of belief, etc. This is also where you can define any real-world contexts you wish your app to react to, such as weather conditions, Moon phases, or specific time windows. Should you require an Epic Undead Champion to spawn near cemeteries, at night, during full moon and a thunderstorm, this is the place where you can configure this.

To define all these different contexts, no matter their complexity, you need to create ProjectTags

ProjectTags

ProjectTags are practically tags that are applied on Cells when their layering conditions are met. For example, creating a ProjectTag with the Layer Node "Location: Park" as a condition will apply this ProjectTag on all Cells that are located in a real-world park. Adding the condition "Weather: Rain" (with an AND logic, see below) to that same ProjectTag will make it apply on the same Cells but only when it's raining. 

You can create as many ProjectTags as you like and each ProjectTag can have as many layering conditions as you deem necessary. 

All the existing ProjectTags can be viewed in the list shown below. You can quickly find/filter the tags with keywords or sort them according to the method of your preference.

To visualize all the contexts and ProjectTags you define in this section check out the Visualization tab.

Creating/Editing ProjectTags - The Nodes Graph

Clicking on the + or any of the ProjectTags will take you to the Nodes Graph where you can create new ProjectTags or configure existing ones.

There are three major Node categories you can use on this Graph: 

Right-clicking anywhere inside the Nodes Graph will bring up the menu shown in the picture, through which you can add any type of new Node depending on how you wish to define the resulting ProjectTag. 

To connect different Nodes simply draw/drag lines between Node Input/Output points as seen above.

All Nodes have a tooltip at their top-right corner which explains their functionality.

You can move round the screen by holding the left mouse button or zoom in/out using the mouse wheel. 

For organizational purposes, all of the Nodes can be freely moved around on this screen and you can group them by adding them in comment frames (from the right-click menu). 

To select multiple Nodes, hold the "Ctrl" key pressed down and click on the individual Nodes you wish to select. To remove Nodes, simply select them and press the "Delete" key on your keyboard.

Finally, can Undo and Redo from the buttons at the top-right corner of the screen and you can Save your changes and Return to the Contexts screen from the buttons at the top-left corner.

Layers

The Layer Nodes follow the Boolean Logic, meaning they return "True" to their Output only if their layering condition applies to the real-world context when a COALA request is made. So for example the Layer Node "Location: Water" will return "False" for every Cell that on land and the Layer Node "Time: 4:00 - 8:00" will only return "True" for COALA requests made between 4:00 and 8:00.

All ProjectTags need at least one Layer Node in some way connected to the Result Node in order to have any functionality. This connection can be done directly from the Layer Node to the Result Node for simple ProjectTags or through Operator Nodes if add more complexity is needed

Of course all of the Layer Nodes can only be used as Input, so they only have an Output point.

The different Layer types that can be added from the Right-click menu are:

Context and POI Layers

As seen in the picture above, all the layers related to some real-world context are colored orange, while the ones related to a POI are pink. For the purpose of the Contexts tab, they function similarly: when a POI is selected as a layering condition for a ProjectTag, then that ProjejectTag will only be applied on Cells which contain the POI in that Layer Node. So for example, the ProjectTag in the image on the right will only apply on Cells that are in a forest and have a Theatre POI in them. 

Operators

More complex ProjectTags will have more than one Layer Nodes. In this case you need to combine these Layers and connect them to the Result Node through the Operator Nodes, which also follow the Boolean Logic. 

Each Operator Node has only one Output point which can be passed to other Operator Nodes or the ProjectTag Result Node, but they can have as many Inputs as needed to create the desired logic.

The Nodes Graph offers four types of Operators to combine the different Layers:

The AND Node will return "True" to its output if all of its inputs have returned "True" while the NOT Node will return "True" if none of its inputs has returned "True".

The OR Node will return "True" to its output if at least one of its inputs has returned "True" while the XOR Node will return "True" if only one of its inputs has returned "True".

ProjectTag Result

Each Nodes Graph can only have one ProjectTag Result Node which cannot be deleted. In this Node you can select an existing ProjectTag from the list, which will effectively update that ProjectTag's properties, or you can create a new ProjectTag by manually typing a new entry. 

Naturally, this Node only has a single Input point. 

A ProjectTag will only apply on a Cell when "True" is entered to its Input.

Weight

The Weight variable is a useful value that can be used as a layering tool. In this column you can give each of your ProjetTags a distinct Weight value which can be later used to determine which ProjectTag will affect a Cell in a certain way. For example, if you want to color Cells in public parks green on your in-app map and ice-cream vendors yellow, you can give the vendor ProjectTag a higher Weight value so that when they both apply on the same Cell, the yellow is displayed to denote that there is an ice-cream vendor in that park.

ProjectTag, Nodes Graph, and Weight Interaction

Something that should be made clear about how these three elements work is that ProjectTags and Node Graphs are distinct entities. It is also possible to connect many different Nodes Graphs (which practically means many different logics) to the same ProjectTag. For example, say that you want to have a ProjectTag named "Water" which will be applied on Cells in the ocean and on Cells where it's currently raining. You can create two separate Graphs and have them both produce the ProjectTag "Water" like in the images below.

What is more, Weight values are assigned to Graphs and NOT ProjectTags, so you can assign different Weights to these two "Water" Graphs. When both of these Graphs' logics are "True" on a Cell (namely on a Cell in the ocean where it's raining) the Weight of the "Water" ProjectTag applied on this Cell will be equal to the sum of the individual Weights of those two Graphs, in this case, 10. 

You may use this feature to trigger different events or to better control the context information in your Cells.

Example Use-case

Undead Champion

Let's say you're making a game and you wish a particularly strong and rare boss monster to appear only at midnight on weekends, with a full moon, during a violent thunderstorm, and only in "Afghanistan" and "Netherlands Antilles". You could then create a ProjectTag as seen in the image below which would only appear in Cells fulfilling these conditions and which you could then use to configure the spawning of this rare enemy.