from role playing game to petrinet the atl way
play

From Role-Playing Game to Petrinet, the ATL way. By Daan Janssens - PowerPoint PPT Presentation

From Role-Playing Game to Petrinet, the ATL way. By Daan Janssens Course: Model-driven Engineering 2013-2014 Supervisor: Prof. Vangheluwe What was ATL again? Read-only Write-only Transformation pattern Rules rule NameOfTheRule { from s:


  1. From Role-Playing Game to Petrinet, the ATL way. By Daan Janssens Course: Model-driven Engineering 2013-2014 Supervisor: Prof. Vangheluwe

  2. What was ATL again?

  3. Read-only Write-only Transformation pattern

  4. Rules rule NameOfTheRule { from s: MMa!ClassA to t: MMb!ClassB ( t.attribute <- s.attribute ) }

  5. Rules Name of the rule rule NameOfTheRule { from Source element on which s: MMa!ClassA rule should be performed to Created target element t: MMb!ClassB ( t.attribute <- s.attribute ) value of attribute of s assigned to } attribute of t.

  6. Experiment

  7. Introduction ● Computer games can be complex ● DSL helps coping with complexity. ● game models can help verificate various game properties. Our interest: the completability of an RPG game

  8. Analysis : RPG Formalism ● Comparable to what we saw in practice ● Main difference: ○ Hero wins when all goals are reached. ○ No villains/traps, focus on path to goals. ○ Tiles are connected by #Connectors Tile 1 Connector Tile 2

  9. Approach Reduced RPG Petrinet Pipe RPG Metamodel Metamodel Metamodel Metamodel Conforms Reduced RPG Petrinet Pipe RPG Model Model Model Model Pipe Python readable Script XML file

  10. Design Drag and drop elements Visual representation Class attribute properties

  11. Design: RPG Metamodel RPG Metamodel:

  12. Design: RPG VS RRPG Metamodel RPG Metamodel: RRPG Metamodel:

  13. Design: RPG VS RRPG Metamodel RPG Metamodel: RRPG Metamodel:

  14. Design: Petrinet vs Pipe Metamodel Petrinet Metamodel: Pipe Metamodel:

  15. Design: Petrinet vs Pipe Metamodel Petrinet Metamodel: Pipe Metamodel: 1-on-1 mapping where additional elements are added

  16. Design: RRPG VS Petrinet RRPG Metamodel: Petrinet Metamodel: ?

  17. Implementation: Initial RPG model initial RPG model: Visual representation

  18. RPG2RRPG

  19. Implementation: RPG2RRPG.atl module RPG2RRPG; Defines metamodels for input model & output model create OUT : RRPG from IN : RPG; helper context RPG!Scene def: getValidTiles : Set(RPG!Tile) = self.tiles->select(c | not .object.oclIsKindOf(RPG!Obstacle)); Helper method getValidTiles on a Scene object of the RPG metamodel returns a subset of its tiles that do not contain Obstacles. Expressions in ATL are written in OCL

  20. Implementation: RPG2RRPG.atl rule Scene2RScene { rule Tile2RTile { from from s : RPG!Scene t : RPG!Tile ( not t.object.oclIsKindOf(RPG!Obstacle) ) to to rs : RRPG!RScene ( rt : RRPG!RTile ( tiles <- (s. getValidTiles ), object <- t.object, connectors <- (s.getValidConnectors) name <- t.name ) ) } } Is applied on every Scene object. Uses a guard to ignore tiles with and only assigns Tiles with no Obstacles. obstacles to them.

  21. RRPG2Petrinet

  22. Implementation: RRPG2Petrinet.atl helper def : id: Integer = 1; rule TileWithHero2Place { from integer variable, to give unique r : MM!RTile ( r = id to each created petrinet element. thisModule.getHero.located ) to p1 : MM1!Place( id <- thisModule.id , tokens <- 1 , 2 variants of rules that work on name <- r.name RTile objects. The other one is for ) tiles without a hero and assigns 0 do { tokens to the created place. thisModule.id <- thisModule.id+1 ; } }

  23. Implementation: RRPG2Petrinet.atl It quickly gets harder and larger! rule Door2DoorPlace { rule Key2KeyPlace { from from r : MM!RDoor r : MM!RKey using{ to Tile : MM!RTile = thisModule.getTileFromObject(r); p1 : MM1!Place( } id <- thisModule.id, to tokens <- 0, a1 : MM1!Arc( name <- ’KeyTaken’ source <- (Tile) , ), target <- (t1), a1 : MM1!Arc( id <- thisModule.id source <- p1, ), multiple created Refering to new target <- thisModule.resolveTemp(r.opens,’t1’) , t1 : MM1!Transition( target elements created id <- thisModule.id+1 id <- thisModule.id+1 ), for a single elements, from ), p2 : MM1!Place( a2 : MM1!Arc( source element within other rules id <- thisModule.id+2, source <- (t1), tokens <- 1, target <- (r.teleports), name <- ’KeyNotYetTaken’ id<- thisModule.id+2 ) ) do { do { thisModule.id <- thisModule.id+3; thisModule.id <- thisModule.id+3; thisModule.elements <- thisModule.elements->including thisModule.elements <- thisModule.elements->including (p1); (a1); thisModule.elements <- thisModule.elements->including thisModule.elements <- thisModule.elements->including(t1); (a1); thisModule.elements <- thisModule.elements->including thisModule.elements <- thisModule.elements->including (a2); (p2); } } } }

  24. Implementation: RRPG2Petrinet.atl It quickly gets harder and larger! rule Door2DoorPlace { rule Key2KeyPlace { from from r : MM!RDoor r : MM!RKey using{ to Tile : MM!RTile = thisModule.getTileFromObject(r); p1 : MM1!Place( } id <- thisModule.id, to tokens <- 0, a1 : MM1!Arc( name <- ’KeyTaken’ source <- (Tile) , ), target <- (t1), a1 : MM1!Arc( id <- thisModule.id source <- p1, ), multiple created Refering to new target <- thisModule.resolveTemp(r.opens,’t1’) , t1 : MM1!Transition( target elements created id <- thisModule.id+1 id <- thisModule.id+1 ), for a single elements, from ), p2 : MM1!Place( a2 : MM1!Arc( source element within other rules id <- thisModule.id+2, source <- (t1), tokens <- 1, target <- (r.teleports), name <- ’KeyNotYetTaken’ id<- thisModule.id+2 ) ) do { do { Too complex for a single presentation! thisModule.id <- thisModule.id+3; thisModule.id <- thisModule.id+3; thisModule.elements <- thisModule.elements->including thisModule.elements <- thisModule.elements->including Read the paper. (p1); (a1); thisModule.elements <- thisModule.elements->including thisModule.elements <- thisModule.elements->including(t1); (a1); thisModule.elements <- thisModule.elements->including thisModule.elements <- thisModule.elements->including (a2); (p2); } } } }

  25. Implementation: RRPG2Petrinet.atl ● Idea is to form the following petrinet constructions: Represents picking up a key and Represents picking up a Goal teleporting. and checking if it was the last one.

  26. Petrinet2Pipe

  27. Implementation: Petrinet2Pipe.atl n : MM1!Name( A 1-on-1 mapping of the Arcs, Transitions and Places, where additional value <- v, elements are added to them. graphics <- g2 An example: ), g2 : MM1!Graphics( rule Place2Place { g1 : MM1!Graphics( ), from position <- pos im : MM1!InitialMarking( p : MM!Place ), value<-v2, to pos : MM1!Position( graphics<-g3 pn : MM1!Place( x <- ’10’, ), id <- p.id.toString(), y <- ’10’ v2 : MM1!Value( graphics <- g1 , ), result<-p.tokens, name <- n , v : MM1!Value( g3 : MM1!Graphics( initialMarking <- im result<-p.name ) ), ),

  28. Implementation: Python script The python script changes XMI files into XML files that can be read by Pipe Pipe.xmi: Pipe.xml: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="iso-8859-1"?> <Pipe:pnml xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns: <pnml> Pipe="http://www.eclipse.org/uml2/4.0.0/UML"> <net id="RPGame" type="P/T net"> <net id="RPGame" type="P/T net"> <transition id="24"> <transition id="24"> <graphics> <graphics> <position x="10" y="10"/> <position x="10" y="10"/> </graphics> </graphics> <orientation> <orientation> <value>1</value> <value result="1"/> </orientation> </orientation> <timed> <timed> <value>true</value> <value result="true"/> </timed> </timed> <name> <name> <graphics/> <graphics/> <value>24</value> <value result="24"/> </name> </name> </transition> </transition>

  29. Result:

  30. Conclusion

  31. Conclusion: ● Amount of rules + size escalates quickly. ● Creation of multiple target objects from single source makes rules complex. ● Lack of visual nature Main conclusion: believe that ATL is the perfect language for performing small/medium sized 1-to-1 mapped transformations.

  32. Comparison with AtomPM: ● Visual representation of rules => more understandable. ● Both offer a visual editor for creating the metamodels. ● AtomPM allows ordering the application of the rules, while ATL executes all rules on their matched source elements at the same time. Main conclusion: Believe that a tool like AtomPM could clear the job in a significant less amount of time and still end up being more readable, reuseable and understandable

  33. Thank you

Recommend


More recommend