Controller.emam 2.16 KB
Newer Older
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
1
/* (c) https://github.com/MontiCore/monticore */
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
2
3
4
5
6
7
8
9
package de.rwth.pacman.heithoff2;

import de.rwth.pacman.heithoff2.BFS.Paths;
import de.rwth.pacman.heithoff2.decision.Decision;
import de.rwth.pacman.heithoff2.coneSearch.ConeSearches;

component Controller {
    ports
10
11
      in Q(-1m: 19m) ghostX[4],
      in Q(0m: 22m) ghostY[4],
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
12
13
14
      in Z(0 : 1 : 3) ghostDirection[4],
      in B ghostEatable[4],
      in B ghostEaten[4],
15
16
      in Q(-1m: 19m) pacManX,
      in Q(0m: 22m) pacManY,
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
17
18
19
20
21
22
23
      in B pacManEaten,
      in Z(0:oo) pacManLives,
      in Z(0:oo) pacManScore,
      in Z^{22,19} map,
      
      out Z(0 : 1 : 3) newPacManDirection;
      
24
25
26
27
    instance Paths safePaths;         // gives back whether certain paths are safe
    instance Decision decision;       // main strategy
    instance ConeSearches coneSearch; // searches for coins and enemies
    instance NormalizePosition normalize;
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
28
      
29
30
    connect ghostX[:] -> normalize.ghostX[:], coneSearch.ghostX[:];
    connect ghostY[:] -> normalize.ghostY[:], coneSearch.ghostY[:];
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
31
    connect ghostDirection[:] -> safePaths.ghostDirection[:], coneSearch.ghostDirection[:];
32
33
34
    connect ghostEatable[:] -> safePaths.ghostEatable[:], coneSearch.ghostEatable[:];
    connect pacManX -> normalize.pacManX, decision.pacManX, coneSearch.currentX;
    connect pacManY -> normalize.pacManY, decision.pacManY, coneSearch.currentY;
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
35
    connect map -> safePaths.map, decision.map, coneSearch.map;
36
37
38
39
    connect normalize.newPacManX -> safePaths.pacManX;
    connect normalize.newPacManY -> safePaths.pacManY;
    connect normalize.newGhostX[:] -> safePaths.ghostX[:];
    connect normalize.newGhostY[:] -> safePaths.ghostY[:]; 
Jean-Marc Ronck's avatar
Jean-Marc Ronck committed
40
41
42
43
44
45
46
47
48
49
50
51
52
    
    connect safePaths.topSafe -> decision.topSafe;
    connect safePaths.bottomSafe -> decision.bottomSafe;
    connect safePaths.leftSafe -> decision.leftSafe;
    connect safePaths.rightSafe -> decision.rightSafe;
    
    connect coneSearch.topValue -> decision.topValue;
    connect coneSearch.bottomValue -> decision.bottomValue;
    connect coneSearch.leftValue -> decision.leftValue;
    connect coneSearch.rightValue -> decision.rightValue;
    
    connect decision.newPacManDirection -> newPacManDirection;
      
Bernhard Rumpe's avatar
BR-sy    
Bernhard Rumpe committed
53
}