====== Game Design Patterns ontology ======
If you would like to use the ontology for your research, please contact [[bgc@agh.edu.pl|Barbara Giżycka]].
==== Based on "Patterns In Game Design" handbook by Staffan Bjork and Jussi Holopainen ====
[[https://drive.google.com/open?id=1iLQ-plTexMF6lNwbqQtngNK81kTU3gfp|Ontology in .OWL]]
===== Description =====
Ontology has only one class: **GDP** (**G**ame **D**esign **P**attern). All patterns are instances of this class.
Following properties are used in ontology:
  * **rdfs:label** -- name of the pattern
  * **rdfs:comment** -- description of the pattern
  * **:example** -- usage of the pattern taken from real game
  * **:instantiated_by**, **:instantiates** -- relations between two patterns
  * **:modulated_by**, **:modulates** -- relations between two patterns
  * **:potentially_conflicting_with** -- relations between two patterns
=====  Use Cases =====
=====  UC.1. Check for conflicts in given set of patterns =====
List of patterns to check have to be specified in IN() clauses. It must be given twice (for `?subject` and for `?object`).
==== Query 1.A ====
PREFIX rdf: 
PREFIX owl: 
PREFIX rdfs: 
PREFIX xsd: 
PREFIX gdp: 
ASK {
    ?subject  gdp:potentially_conflicting_with  ?object .
    FILTER(?subject  IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment) )
    FILTER(?object  IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment) )
}
**Result:** *TRUE* *(= Yes, there are conflicts in given set)*  
To see actual conflicts, change `ASK` into `SELECT *`}
==== Query 1.B ====
PREFIX rdf: 
PREFIX owl: 
PREFIX rdfs: 
PREFIX xsd: 
PREFIX gdp: 
ASK {
    ?subject  gdp:potentially_conflicting_with  ?object .
    FILTER(?subject  IN(gdp:conflict, gdp:self-facilitated_games, gdp:ability_losses) )
    FILTER(?object  IN(gdp:conflict, gdp:self-facilitated_games, gdp:ability_losses) )
}
**Result:** *FALSE* *(= No, there are no conflicts in given set)*
===== UC.2. Check for conflicts in given set of patterns (using `instantiated_by` relation) =====
==== Query 2.A ====
PREFIX rdf: 
PREFIX owl: 
PREFIX rdfs: 
PREFIX xsd: 
PREFIX gdp: 
ASK {
    {
        ?subject  gdp:instantiated_by  ?instantiated_by_object .
        ?instantiated_by_object  gdp:potentially_conflicting_with  ?object
    } UNION {  
        ?subject  gdp:potentially_conflicting_with  ?object
    }
    FILTER(?subject  IN(gdp:conflict, gdp:self-facilitated_games, gdp:ability_losses) )
    FILTER(?instantiated_by_object  NOT IN(gdp:conflict, gdp:self-facilitated_games, gdp:ability_losses) )
    FILTER(?object  IN(gdp:conflict, gdp:self-facilitated_games, gdp:ability_losses) )
}
**Result:** *TRUE* *(= Yes, there are conflicts in given set)*
===== UC.3. Select all items that are in given relation with our set of patterns =====
==== Query 3.A `instantiates` ====
Note: The query is looking for everything that is in the `instantiates` relationship. But for us enough is just one such thing for each of our patterns.
PREFIX rdf: 
PREFIX owl: 
PREFIX rdfs: 
PREFIX xsd: 
PREFIX gdp: 
SELECT ?subject
WHERE {
    ?subject  gdp:instantiates  ?object.
    FILTER( ?object IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment, gdp:preventing_goals) )
    FILTER( ?subject NOT IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment, gdp:preventing_goals) )
}
GROUP BY (?subject)
==== Query 3.B other relations ====
Note: as above...
PREFIX rdf: 
PREFIX owl: 
PREFIX rdfs: 
PREFIX xsd: 
PREFIX gdp: 
SELECT ?subject
WHERE {
    ?subject  gdp:instantiated_by | gdp:modulated_by | gdp:modulates  ?object.
    FILTER( ?object IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment, gdp:preventing_goals) )
    FILTER( ?subject NOT IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment, gdp:preventing_goals) )
}
GROUP BY (?subject)
==== Query 3.C other relations AND checked in two ways (?sub ?rel ?obj AND ?obj ?rel ?subj) ====
Note: as above...
PREFIX rdf: 
PREFIX owl: 
PREFIX rdfs: 
PREFIX xsd: 
PREFIX gdp: 
SELECT ?subject
WHERE {
    {
        ?subject  gdp:instantiated_by | gdp:modulated_by | gdp:modulates  ?object.
    } UNION {
        ?object  gdp:instantiates | gdp:modulated_by | gdp:modulates  ?subject.
    }
    FILTER( ?object IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment, gdp:preventing_goals) )
    FILTER( ?subject NOT IN(gdp:conflict, gdp:uncertainty_of_information, gdp:alignment, gdp:preventing_goals) )
}
GROUP BY (?subject)