Merge branch 'master' of git.inpt.fr:tocard-inc/enseeiht/gls/projet

This commit is contained in:
Laurent Fainsin 2022-01-16 16:05:30 +01:00
commit bdd0437452
2 changed files with 132 additions and 16 deletions

View file

@ -52,6 +52,13 @@ def: getJeu() : game!Jeu =
->asSequence()
->first();
helper context String
def: getTaille() : Integer =
game!Objet.allInstances()
->asSequence()
->select(o | o.nom.nom = self)
->first().taille;
helper context game!Lieu
def : estDepart() : Integer =
self.depart.condition
@ -68,12 +75,19 @@ helper def: getNetwork() : petrinet!Network =
->asSequence()->first();
-- Obtenir la taille de l'explorateur
helper context petrinet!Place
helper context String
def: getTailleExp() : Integer =
game!Explorateur.allInstances()
->asSequence()
->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
helper context game!Objet
def : getNombreInit() : Integer =
@ -114,6 +128,16 @@ def: getPlace(): petrinet!Place =
->asSequence()
->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
def : getObjet() : game!Objet =
game!Objet.allInstances()
@ -131,16 +155,6 @@ def: getLieu(): game!Lieu =
->asSequence()
->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
def : getInteraction() : game!Interaction =
game!Interaction.allInstances()
@ -183,7 +197,7 @@ rule Objet2PetriNet {
p_objneg: petrinet!Place(
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())
}
@ -247,6 +261,19 @@ rule Chemin2PetriNet {
for (con in c.connaissances) {
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
to
t: petrinet!Transition(
name <- 'interaction_' + i.nom.nom,
name <- 'interaction_' + i.nom.nom + '_' + i.getPersonne().nom.nom,
network <- i.getJeu()),
arcOut: petrinet!Arc(
@ -278,6 +305,23 @@ rule Interaction2PetriNet {
for (c in i.connaissances) {
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)
}
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) {
to
arc : petrinet!Arc(

View file

@ -8,8 +8,8 @@ pl personne_Sphinx (0)
pl lieu_Enigme (1)
pl lieu_Succes (0)
pl lieu_Echec (0)
tr chemin_win lieu_Enigme*1 -> lieu_Succes*1
tr chemin_loose lieu_Enigme*1 -> lieu_Echec*1
tr interaction_Parler lieu_Enigme*1 -> personne_Sphinx*1
tr chemin_win lieu_Enigme*1 connaissance_Reussite*1 -> lieu_Succes*1 connaissance_Reussite*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_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_2 personne_Sphinx*1 objet_tentative*1 -> lieu_Enigme*1 objet_tentative_neg*1 taille*1