340 likes | 473 Views
Programmed Graph Rewriting with Time for Simulation-Based Design. Eugene Syriani Hans Vangheluwe. Programmed Graph Rewriting with Time for Simulation-Based Design. Eugene Syriani Hans Vangheluwe. Overview. Background In the context The Modular Timed Graph Transformation (MoTiF) language
E N D
Programmed Graph Rewriting with Time for Simulation-Based Design Eugene Syriani Hans Vangheluwe
Programmed Graph Rewriting with Time for Simulation-Based Design Eugene Syriani Hans Vangheluwe
Overview • Background • In the context • The Modular Timed Graph Transformation (MoTiF) language • Case Study: Reactive PacMan Game • Modelling, Simulation and Synthesis • Modelling of transformation and its environment • Simulation for optimization • Synthesis of application • Conclusion and Future Work
In the context • Model Transformation Graph Transformation • Controlled Graph Rewriting (rewriting rules) • Control Primitives : Sequencing, Branching, Looping, Parallelism, Hierarchy • Time is inherent in our transformation models Modelling, Simulation and Synthesis
In the context Model of System Model of Environment Simulation Experiments Synthesis of Application
Motif: Semantic Domain • The Discrete Event System Specification [1] (DEVS) formalism • Highly compositional simulation framework • DEVS: • Blocks • Ports • Events • Semantics: Parallel composition of blocks/models [1] Zeigler B.P., Multifacetted Modelling and Discrete Event Simulation/ Academic Press, London (1984)
Motif: Semantic Domain • Atomic DEVS: • Time Advance • Output Function • Internal Transition • External Transition ATOMIC
Motif: Semantic Domain Coupled DEVS C1 A1 C2 A2
Motif [2] • Blocks • Atomic: encapsulate a graph rewriting rule • Coupled: encapsulate a set of rules (graph grammar) • Events • Inport: receive the host graph • Outport(s): send the transformed graph [2] Syriani E. and Vangheluwe H.: Programmed Graph Rewriting with DEVS. AGTIVE 2007, LNCS (2008)
MotifModelling Environment in AToM3 [3] [3] de Lara J., Vangheluwe H., AToM3: A tool for multi-formalism and meta-modelling. FASE, LNCS 2306 (2002), 174-188
Motif Execution class Pacmaneat: def match(): … def execute(): … class Pacmanmoveri: def match(): … def execute(): … class Pacmandie: def match(): … def execute(): … COMPILE IMPORT class Kill(ARule): def __init__(self): ARule.__init__(self, name=‘Kill') self.state = ARuleState(Pacdie()) def weightFunction(self): return 1.0 SIMULATE GENERATE
Case Study: Reactive PacMan Game Simplified PacMan formalism [4] [4] Heckel R., Graph Transformation in a nutshell. FoVMT, ENTCS 148 (2006), 187-198
1 1 Case Study: Reactive PacMan Game 4 4 2 2 Build the Graph Rewriting Rules 5 pacLink pacLink 3 3 6 foodLink 1: Match[1].score + 1 5 pacLink 1 1 4 2 2 3 3 ghostLink ghostLink
Case Study: Reactive PacMan Game Build the Graph Rewriting Rules ghostLink ghostLink 6 1 2 1 2 5 3 3 gridLeft gridLeft 4 4 pacLink pacLink 5 1 2 1 2 6 3 3 gridRight 4 gridRight 4
Model of System Model of Environment Simulation Experiments Synthesis of Application
Modelling of The transformation: System • User – Controller – Autonomous loop • Feed-back to User • On User interrupt: User Controlled • Feed-back to User User Controlled Autonomous
Modelling of The transformation: Autonomous CRule Priorities
Modelling of The transformation: GhostMoveCRule Decider finds the next move for the ghost Decider consumes time
Modelling of transformation: System User Controlled Autonomous
Modelling of The transformation: UserControlledCRule Conditional rule execution
Modelling of The transformation: System User Controlled Autonomous
Modelling of environment: User CoupledBlock • Customization • Modularity User Behavior User Interaction
Model of the player: STRATEGY class Key: up = 'u' down = 'd' left = 'l' right = 'r' keys = [up, down, left, right] def nextRandom(self): import random return random.Random().choice(Key.keys) Smart Dummy Random
Modelling of environment: UserBehaviorCoupledBlock Back-tracking Collector consumes time
Modelling of environment: TryMoveCRule pacLink ghostLink pacLink 6 1 2 1 2 1 5 8 3 3 7 gridRight 4 gridRight 4 • Non-determinism
Model of the player: SPEED Player reaction time [5]: • Thinking time • Motorics time • Slow • Normal • Fast • Very Fast [5] Zaitev A.V., Skorik Y.A., Mathematical description of sensorimotor reaction time distribution, Human Psychology 28(4) (2002), 494-497
Model of System Model of Environment Simulation Experiments Synthesis of Application
Why do we need simulation? We want to build a “playable” game • A.I. Strategy Random – Smart – Very Smart • Speed Too Slow – … – Too Fast Fix Strategy: Very Smart Find optimal speed
SIMULATION results Finding the optimal game speed
Model of System Model of Environment Simulation Experiments Synthesis of Application
Synthesis of application • Synthesis of a reactive game • Discard the UserBehavior block • Runs on a web browser using AJAX and SVG • Real-time model transformation User Interaction User Behavior User Interaction
Summary MoTiF allows for • Modelling and Simulation-Based Design • Graph transformation rules • Timed transformation system • User • Synthesis of applications • Reactive • Real-time Model Everything User Controlled Autonomous
future work • Model A.I. behavior: backtracking • Re-use and parametrisation of transformation models • MORE COMPLEX EXAMPLES