feat: exemple to tina fonctionne
This commit is contained in:
parent
d019450ae4
commit
e746172535
|
@ -52,6 +52,13 @@ def: getJeu() : game!Jeu =
|
||||||
->asSequence()
|
->asSequence()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
helper context String
|
||||||
|
def: getTaille() : Integer =
|
||||||
|
game!Objet.allInstances()
|
||||||
|
->asSequence()
|
||||||
|
->select(o | o.nom.nom = self)
|
||||||
|
->first().taille;
|
||||||
|
|
||||||
helper context game!Lieu
|
helper context game!Lieu
|
||||||
def : estDepart() : Integer =
|
def : estDepart() : Integer =
|
||||||
self.depart.condition
|
self.depart.condition
|
||||||
|
@ -68,12 +75,19 @@ helper def: getNetwork() : petrinet!Network =
|
||||||
->asSequence()->first();
|
->asSequence()->first();
|
||||||
|
|
||||||
-- Obtenir la taille de l'explorateur
|
-- Obtenir la taille de l'explorateur
|
||||||
helper context petrinet!Place
|
helper context String
|
||||||
def: getTailleExp() : Integer =
|
def: getTailleExp() : Integer =
|
||||||
game!Explorateur.allInstances()
|
game!Explorateur.allInstances()
|
||||||
->asSequence()
|
->asSequence()
|
||||||
->first().tailleInventaire;
|
->first().tailleInventaire;
|
||||||
|
|
||||||
|
helper context String
|
||||||
|
def: getTransition() : petrinet!Transition =
|
||||||
|
petrinet!Transition.allInstances()
|
||||||
|
->asSequence()
|
||||||
|
->select(t | t.name = self)
|
||||||
|
->first();
|
||||||
|
|
||||||
-- Nombre d'objets initiaux de l'explo
|
-- Nombre d'objets initiaux de l'explo
|
||||||
helper context game!Objet
|
helper context game!Objet
|
||||||
def : getNombreInit() : Integer =
|
def : getNombreInit() : Integer =
|
||||||
|
@ -114,6 +128,16 @@ def: getPlace(): petrinet!Place =
|
||||||
->asSequence()
|
->asSequence()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
helper context game!Interaction
|
||||||
|
def: getPersonne(): game!Personne =
|
||||||
|
game!Personne.allInstances()
|
||||||
|
->select(p | (p.interactions
|
||||||
|
->select(i | i = self)
|
||||||
|
->size()
|
||||||
|
) > 0)
|
||||||
|
->asSequence()
|
||||||
|
->first();
|
||||||
|
|
||||||
helper context String
|
helper context String
|
||||||
def : getObjet() : game!Objet =
|
def : getObjet() : game!Objet =
|
||||||
game!Objet.allInstances()
|
game!Objet.allInstances()
|
||||||
|
@ -131,16 +155,6 @@ def: getLieu(): game!Lieu =
|
||||||
->asSequence()
|
->asSequence()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
helper context game!Interaction
|
|
||||||
def : getPersonne() : game!Personne =
|
|
||||||
game!Personne.allInstances()
|
|
||||||
->select(p | p.interactions
|
|
||||||
->select(i | i.nom.nom = self.nom.nom)
|
|
||||||
->asSequence()
|
|
||||||
->size() > 0)
|
|
||||||
->asSequence()
|
|
||||||
->first();
|
|
||||||
|
|
||||||
helper context game!Action
|
helper context game!Action
|
||||||
def : getInteraction() : game!Interaction =
|
def : getInteraction() : game!Interaction =
|
||||||
game!Interaction.allInstances()
|
game!Interaction.allInstances()
|
||||||
|
@ -183,7 +197,7 @@ rule Objet2PetriNet {
|
||||||
|
|
||||||
p_objneg: petrinet!Place(
|
p_objneg: petrinet!Place(
|
||||||
name <- 'objet_' + o.nom.nom + '_neg',
|
name <- 'objet_' + o.nom.nom + '_neg',
|
||||||
tokens <- p_objneg.getTailleExp() div o.taille - o.getNombreInit(),
|
tokens <- ''.getTailleExp() div o.taille - o.getNombreInit(),
|
||||||
network <- o.getJeu())
|
network <- o.getJeu())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +261,19 @@ rule Chemin2PetriNet {
|
||||||
for (con in c.connaissances) {
|
for (con in c.connaissances) {
|
||||||
thisModule.recuConn(t, con.nom);
|
thisModule.recuConn(t, con.nom);
|
||||||
}
|
}
|
||||||
|
for (cond in c.visible.condition) {
|
||||||
|
for (cond2 in cond.conditionTest) {
|
||||||
|
if (cond2.oclIsKindOf(game!ConditionObjet)) {
|
||||||
|
thisModule.readObjetEga(t, cond2.objet, cond2.nombre);
|
||||||
|
} else {
|
||||||
|
if (cond2.negation = '!') {
|
||||||
|
thisModule.readConnNeg(t, cond2.connaissance);
|
||||||
|
} else {
|
||||||
|
thisModule.readConn(t, cond2.connaissance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +281,7 @@ rule Interaction2PetriNet {
|
||||||
from i: game!Interaction
|
from i: game!Interaction
|
||||||
to
|
to
|
||||||
t: petrinet!Transition(
|
t: petrinet!Transition(
|
||||||
name <- 'interaction_' + i.nom.nom,
|
name <- 'interaction_' + i.nom.nom + '_' + i.getPersonne().nom.nom,
|
||||||
network <- i.getJeu()),
|
network <- i.getJeu()),
|
||||||
|
|
||||||
arcOut: petrinet!Arc(
|
arcOut: petrinet!Arc(
|
||||||
|
@ -278,6 +305,23 @@ rule Interaction2PetriNet {
|
||||||
for (c in i.connaissances) {
|
for (c in i.connaissances) {
|
||||||
thisModule.recuConn(t, c.nom);
|
thisModule.recuConn(t, c.nom);
|
||||||
}
|
}
|
||||||
|
for (cond in i.getPersonne().visible.condition) {
|
||||||
|
for (cond2 in cond.conditionTest) {
|
||||||
|
if (cond2.oclIsKindOf(game!ConditionObjet)) {
|
||||||
|
if (cond2.comparateur = '==') {
|
||||||
|
thisModule.readObjetEga(('interaction_' + i.nom.nom + '_' + i.getPersonne().nom.nom).getTransition(), cond2.objet, cond2.nombre);
|
||||||
|
} else if (cond2.comparateur = '>') {
|
||||||
|
thisModule.readObjetSup(('interaction_' + i.nom.nom + '_' + i.getPersonne().nom.nom).getTransition(), cond2.objet, cond2.nombre);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (cond2.negation = '!') {
|
||||||
|
thisModule.readConnNeg(('interaction_' + i.nom.nom + '_' + i.getPersonne().nom.nom).getTransition(), cond2.connaissance);
|
||||||
|
} else {
|
||||||
|
thisModule.readConn(('interaction_' + i.nom.nom + '_' + i.getPersonne().nom.nom).getTransition(), cond2.connaissance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +377,78 @@ rule consoObjet(t : game!Transition, s : String) {
|
||||||
weight <- s.getObjet().taille)
|
weight <- s.getObjet().taille)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rule readObjetEga(t : game!Transition, s : String, n : Integer) {
|
||||||
|
to
|
||||||
|
arc : petrinet!Arc(
|
||||||
|
place <- t.getPlace('objet_' + s),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- false,
|
||||||
|
weight <- n),
|
||||||
|
|
||||||
|
arc2 : petrinet!Arc(
|
||||||
|
place <- t.getPlace('objet_' + s),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- true,
|
||||||
|
weight <- n),
|
||||||
|
|
||||||
|
arc_neg : petrinet!Arc(
|
||||||
|
place <- t.getPlace('objet_' + s + '_neg'),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- false,
|
||||||
|
weight <- (s.getTailleExp() div s.getTaille()) - n),
|
||||||
|
|
||||||
|
arc2_neg : petrinet!Arc(
|
||||||
|
place <- t.getPlace('objet_' + s + '_neg'),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- true,
|
||||||
|
weight <- (s.getTailleExp() div s.getTaille()) - n)
|
||||||
|
}
|
||||||
|
|
||||||
|
rule readObjetSup(t : game!Transition, s : String, n : Integer) {
|
||||||
|
to
|
||||||
|
arc : petrinet!Arc(
|
||||||
|
place <- t.getPlace('objet_' + s),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- false,
|
||||||
|
weight <- n + 1),
|
||||||
|
|
||||||
|
arc2 : petrinet!Arc(
|
||||||
|
place <- t.getPlace('objet_' + s),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- true,
|
||||||
|
weight <- n + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
rule readConn(t : game!Transition, s : String) {
|
||||||
|
to
|
||||||
|
arc : petrinet!Arc(
|
||||||
|
place <- t.getPlace('connaissance_' + s),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- false,
|
||||||
|
weight <- 1),
|
||||||
|
|
||||||
|
arc2 : petrinet!Arc(
|
||||||
|
place <- t.getPlace('connaissance_' + s),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- true,
|
||||||
|
weight <- 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
rule readConnNeg(t : game!Transition, s : String) {
|
||||||
|
to
|
||||||
|
arc : petrinet!Arc(
|
||||||
|
place <- t.getPlace('connaissance_' + s + '_neg'),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- false,
|
||||||
|
weight <- 1),
|
||||||
|
|
||||||
|
arc2 : petrinet!Arc(
|
||||||
|
place <- t.getPlace('connaissance_' + s + '_neg'),
|
||||||
|
transition <- t,
|
||||||
|
outgoing <- true,
|
||||||
|
weight <- 1)
|
||||||
|
}
|
||||||
|
|
||||||
rule recuObjet(t : game!Transition, s : String) {
|
rule recuObjet(t : game!Transition, s : String) {
|
||||||
to
|
to
|
||||||
arc : petrinet!Arc(
|
arc : petrinet!Arc(
|
||||||
|
|
|
@ -8,8 +8,8 @@ pl personne_Sphinx (0)
|
||||||
pl lieu_Enigme (1)
|
pl lieu_Enigme (1)
|
||||||
pl lieu_Succes (0)
|
pl lieu_Succes (0)
|
||||||
pl lieu_Echec (0)
|
pl lieu_Echec (0)
|
||||||
tr chemin_win lieu_Enigme*1 -> lieu_Succes*1
|
tr chemin_win lieu_Enigme*1 connaissance_Reussite*1 -> lieu_Succes*1 connaissance_Reussite*1
|
||||||
tr chemin_loose lieu_Enigme*1 -> lieu_Echec*1
|
tr chemin_loose lieu_Enigme*1 objet_tentative*0 objet_tentative_neg*3 -> lieu_Echec*1 objet_tentative*0 objet_tentative_neg*3
|
||||||
tr interaction_Parler lieu_Enigme*1 -> personne_Sphinx*1
|
tr interaction_Parler_Sphinx lieu_Enigme*1 connaissance_Reussite_neg*1 objet_tentative*1 -> personne_Sphinx*1 connaissance_Reussite_neg*1 objet_tentative*1
|
||||||
tr action_Reponse_1 personne_Sphinx*1 connaissance_Reussite_neg*1 -> lieu_Enigme*1 connaissance_Reussite*1
|
tr action_Reponse_1 personne_Sphinx*1 connaissance_Reussite_neg*1 -> lieu_Enigme*1 connaissance_Reussite*1
|
||||||
tr action_Reponse_2 personne_Sphinx*1 objet_tentative*1 -> lieu_Enigme*1 objet_tentative_neg*1 taille*1
|
tr action_Reponse_2 personne_Sphinx*1 objet_tentative*1 -> lieu_Enigme*1 objet_tentative_neg*1 taille*1
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue