SPARQL Behavior Tree - aantakli/AJAN-service GitHub Wiki
The Behavior Tree (BT) paradigm is designed to define agent behavior or its decision-making process. It is widely used in the gaming industry and in robotics. BTs are characterized by their modular and graphical properties, making them highly extendable and easy to use even by non-experts. This paradigm with loops, sequences, parallels and an implicit knowledge base is often described as a combination of decision trees with state machines. Typically, a BT is executed sequentially in a depth-first procedure, whereby the reactivity of the agent is realized. Goals are implicitly defined and their priority is specified by the hierarchical structure of the tree. The modularity and reusability of this paradigm results from the fact that the individual tree nodes only pass their status (in the order: FRESH -> RUNNING -> SUCCEEDED or FAILED or ABORTED) to parent nodes and obtain necessary information on a shared knowledge base (KB). According to Colledanchise and Ogren there are four basic node types from which a BT can be built: the root node; composite nodes like Sequence, Priority or Parallel; decorator nodes like Invert and Repeat; and leaf nodes like Action and Condition.
A deeper introduction into BTs paradigm can be found under: gdx-ai.
For modeling agent behavior in LD domains, AJAN uses the SPARQL-BT (SBT in short) approach, an extension of the well known BT paradigm. SBT, as one might expect, is a combination of the BT paradigm with SPARQL. The data model used to describe SBTs is RDF.
Basically, BTs are used in AJAN to perform contextual SPARQL queries for state checking, updating, constructing RDF data used for action executions, or to control the internal execution of a AJAN agent behavior. Furthermore, SBTs are defined in RDF, whereby a semantic description of the behaviors they implement is available and to meet the requirements of the LD paradigm. SBTs use standard BT composite and decorator nodes and are processed like typical BTs (used BT lib. gdx-ai), but this approach defines multiple new node (see chapters: SPARQL-BT Branch Nodes, SPARQL-BT Leaf Nodes and SPARQL-BT Events) types to work on RDF-based datasets and resources using SPARQL queries. Thus, a SBT can always access one or more triplestores via SPARQL endpoints that follow the SPARQL protocol.
Description: The root node is the entry point of a BT and has only one child. If this child is successful, the entire BT is successful.
###Properties##
Property (RDF) | Value (RDF) |
---|---|
Namespace (@prefix bt:) | URL (http://www.ajan.de/behavior/bt-ns#) |
Type (rdf:type) | Behavior Tree (bt:BehaviorTree) |
Type (rdf:type) | Root Node (bt:Root) |
Class (rdfs:subClassOf) | Task Node (bt:Task) |
Label (rdfs:label) | <string> ("some label"^^xsd:string) |
Child (bt:hasChild) | URI of a SPARQL-BT node (URI of rdf:type bt:Task) |
To model SPARQL-BT either the AJAN editor (currently not available) or the Turtle/RDF definitions file can be used: \ajan-service\executionservice\use-case\behaviors\behaviors.ttl
Example in Turtle/RDF (comments strat with: #)
@prefix : <http://localhost:8090/rdf4j/repositories/behaviors#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix bt: <http://www.ajan.de/behavior/bt-ns#> .
:ExampleBehavior
a bt:BehaviorTree ;
a bt:Root ;
rdfs:label "ExampleBehavior"^^xsd:string ;
bt:hasChild # some child Node .
SPARQL-BT examples (in TURTLE/RDF) can be found in this repository at:
\ajan-service\executionservice\use-case\behaviors\behaviors.ttl
And see chapters: see chapters: SPARQL-BT Branch Nodes, SPARQL-BT Leaf Nodes and SPARQL-BT Events