Aufgrund einer Wartung wird GitLab am 25.01 zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 25.01 between 8:00 and 9:00 am.

GeneralStrategy.emam 903 Bytes
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
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package de.rwth.supermario.haller.actuator;



component GeneralStrategy {
    ports
        in Z^{1,2} marioPosition,
        in Q tickSize,
        out Z jumpAdvice,
        out Z crouchAdvice,
        out Z directionAdvice;


    implementation Math {
        //Wait one seconds before being "stuck"
        Z maxTicks = 0.5 * tickSize; 
  
        static Z ticksOnSamePosition = 0;
        static Z oldXPos = -1;
        
        if oldXPos == marioPosition(1,1)
            ticksOnSamePosition = ticksOnSamePosition + 1;
        else
            oldXPos = marioPosition(1,1);
            ticksOnSamePosition = 0;
        end
        
        if(ticksOnSamePosition > maxTicks)
            jumpAdvice = 1;
        else
            jumpAdvice = 0;
        end
    
        directionAdvice = 1;
            
        crouchAdvice = 0;
    }

        
}