feat: ajout du ATL de dams
This commit is contained in:
parent
05b85ab56c
commit
dffb53750f
|
@ -2,53 +2,266 @@ module Game2PetriNet;
|
|||
create OUT: petrinet from IN: game;
|
||||
|
||||
|
||||
-- Obtenir la place correspondant au predecesseur d'une WorkSequence
|
||||
|
||||
|
||||
helper context game!Explorateur
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Objet
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Connaissance
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Action
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Personne
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Chemin
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Lieu
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Interaction
|
||||
def: getJeu() : game!Jeu =
|
||||
game!Jeu.allInstances()
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Lieu
|
||||
def : estDepart() : Integer =
|
||||
self.depart.condition
|
||||
->select(ce | ce.conditionTest
|
||||
->select(ct | ct.oclIsTypeOf(game!ConditionBoolean))
|
||||
->select(ct | ct.valeur = 'true')
|
||||
->size() > 0)
|
||||
->size();
|
||||
|
||||
-- Obtenir le network
|
||||
helper def: getNetwork() : petrinet!Network =
|
||||
petrinet!Network.allInstances()
|
||||
->select(n | n.name = 'jeu')
|
||||
->asSequence()->first();
|
||||
|
||||
-- Obtenir la transition correspondant au successeur d'une WorkSequence
|
||||
-- Obtenir la taille de l'explorateur
|
||||
helper context petrinet!Place
|
||||
def: getTailleExp() : Integer =
|
||||
game!Explorateur.allInstances()
|
||||
->asSequence()
|
||||
->first().tailleInventaire;
|
||||
|
||||
-- Nombre d'objets initiaux de l'explo
|
||||
helper context game!Objet
|
||||
def : getNombreInit() : Integer =
|
||||
game!Explorateur.allInstances()
|
||||
->asSequence()
|
||||
->first().objets
|
||||
->select(o | o.nom = self.nom.nom)
|
||||
->size();
|
||||
|
||||
-- Nombre de connaissances initiaux de l'explo
|
||||
helper context game!Connaissance
|
||||
def : getNombreInit() : Integer =
|
||||
game!Explorateur.allInstances()
|
||||
->asSequence()
|
||||
->first().connaissances
|
||||
->select(c | c.nom = self.nom.nom)
|
||||
->size();
|
||||
|
||||
-- Nombre de place libre itiale de l'explo
|
||||
helper context game!Explorateur
|
||||
def : getNombreInit() : Integer =
|
||||
game!Objet.allInstances()
|
||||
->asSequence()
|
||||
->iterate(o; res : Integer = self.tailleInventaire | res - o.getNombreInit() * o.taille);
|
||||
|
||||
-- Obtenir la place d'un chemin (in / out)
|
||||
helper context game!Chemin
|
||||
def: getPlaceOf(s : String): petrinet!Place =
|
||||
petrinet!Place.allInstances()
|
||||
->select(p | p.name = s)
|
||||
->asSequence()->first();
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Lieu
|
||||
def: getPlace(): petrinet!Place =
|
||||
petrinet!Place.allInstances()
|
||||
->select(p | p.name = 'lieu_' + self.nom.nom)
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
helper context game!Personne
|
||||
def: getLieu(): game!Lieu =
|
||||
game!Lieu.allInstances()
|
||||
->select(l | l.personnes
|
||||
->select(p | p.nom = self.nom.nom)
|
||||
->asSequence()
|
||||
->size() > 0)
|
||||
->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()
|
||||
->select(i | i.actions
|
||||
->select(a | a.nom.nom = self.nom.nom)
|
||||
->asSequence()
|
||||
->size() > 0)
|
||||
->asSequence()
|
||||
->first();
|
||||
|
||||
|
||||
|
||||
-- Traduire un Jeu en un PetriNet de même nom
|
||||
rule Game2PetriNet {
|
||||
from p: game!Jeu
|
||||
to pn: petrinet!Network (name <- 'jeu')
|
||||
}
|
||||
|
||||
-- Traduire un Lieu en un motif sur le réseau de Petri
|
||||
rule Explorateur2Petrinet {
|
||||
from e: game!Explorateur
|
||||
to
|
||||
p: petrinet!Place(
|
||||
name <- 'taille',
|
||||
tokens <- e.getNombreInit(),
|
||||
network <- e.getJeu())
|
||||
}
|
||||
|
||||
rule Objet2PetriNet {
|
||||
from o: game!Objet
|
||||
to
|
||||
p_obj: petrinet!Place(
|
||||
name <- 'objet_' + o.nom.nom,
|
||||
tokens <- o.getNombreInit(),
|
||||
network <- o.getJeu()),
|
||||
|
||||
p_objneg: petrinet!Place(
|
||||
name <- 'objet_' + o.nom.nom + '_neg',
|
||||
tokens <- p_objneg.getTailleExp() div o.taille - o.getNombreInit(),
|
||||
network <- o.getJeu())
|
||||
}
|
||||
|
||||
rule Connaissance2PetriNet {
|
||||
from c: game!Connaissance
|
||||
to
|
||||
p_con: petrinet!Place(
|
||||
name <- 'connaissance_' + c.nom.nom,
|
||||
tokens <- c.getNombreInit(),
|
||||
network <- c.getJeu()),
|
||||
|
||||
p_conneg: petrinet!Place(
|
||||
name <- 'connaissance_' + c.nom.nom + '_neg',
|
||||
tokens <- 1 - c.getNombreInit(),
|
||||
network <- c.getJeu())
|
||||
}
|
||||
|
||||
rule Personne2PetriNet {
|
||||
from p: game!Personne
|
||||
to
|
||||
pers: petrinet!Place(
|
||||
name <- 'personne_' + p.nom.nom,
|
||||
tokens <- 0,
|
||||
network <- p.getJeu())
|
||||
}
|
||||
|
||||
rule Lieu2PetriNet {
|
||||
from l: game!Lieu
|
||||
to
|
||||
-- PLACES d'un Lieu
|
||||
p: petrinet!Place(
|
||||
name <- 'lieu_' + l.nom.nom,
|
||||
tokens <- 0,
|
||||
network <- p.getNetwork())
|
||||
tokens <- l.estDepart(),
|
||||
network <- l.getJeu())
|
||||
}
|
||||
|
||||
-- Traduire une WorkDefinition en un motif sur le réseau de Petri
|
||||
rule Chemin2PetriNet {
|
||||
from c: game!Chemin
|
||||
to
|
||||
-- TRANSITIONS d'un Chemin
|
||||
t: petrinet!Transition(
|
||||
name <- 'chemin_' + c.Nom.nom,
|
||||
network <- t.getNetwork()),
|
||||
-- ARCS d'un Chemin
|
||||
name <- 'chemin_' + c.nom.nom,
|
||||
network <- c.getJeu()),
|
||||
|
||||
arcIn: petrinet!Arc(
|
||||
place <- c.getPlaceOf('lieu_' + c.lieuIn.nom.nom),
|
||||
place <- c.getPlaceOf('lieu_' + c.lieuIn.nom),
|
||||
transition <- t,
|
||||
outgoing <- false,
|
||||
weight <- 1),
|
||||
|
||||
arcOut: petrinet!Arc(
|
||||
place <- c.getPlaceOf('lieu_' + c.lieuOu.nom.nom),
|
||||
place <- c.getPlaceOf('lieu_' + c.lieuOut.nom),
|
||||
transition <- t,
|
||||
outgoing <- true,
|
||||
weight <- 1)
|
||||
}
|
||||
}
|
||||
|
||||
rule Interaction2PetriNet {
|
||||
from i: game!Interaction
|
||||
to
|
||||
t: petrinet!Transition(
|
||||
name <- 'interaction_' + i.nom.nom,
|
||||
network <- i.getJeu()),
|
||||
|
||||
arcOut: petrinet!Arc(
|
||||
place <- i.getPersonne(),
|
||||
transition <- t,
|
||||
outgoing <- true,
|
||||
weight <- 1),
|
||||
|
||||
arcIn: petrinet!Arc(
|
||||
place <- i.getPersonne().getLieu().getPlace(),
|
||||
transition <- t,
|
||||
outgoing <- false,
|
||||
weight <- 1)
|
||||
}
|
||||
|
||||
rule Action2PetriNet {
|
||||
from a: game!Action
|
||||
to
|
||||
t: petrinet!Transition(
|
||||
name <- 'action_' + a.nom.nom,
|
||||
network <- a.getJeu()),
|
||||
|
||||
arcIn: petrinet!Arc(
|
||||
place <- a.getInteraction().getPersonne(),
|
||||
transition <- t,
|
||||
outgoing <- false,
|
||||
weight <- 1),
|
||||
|
||||
arcOut: petrinet!Arc(
|
||||
place <- a.getInteraction().getPersonne().getLieu().getPlace(),
|
||||
transition <- t,
|
||||
outgoing <- true,
|
||||
weight <- 1)
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue