You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.7 KiB

mdp
const int lanes = 5; // Counting the sidewalks as lanes
const int streetLength = 20;
const int maxVelocity = 3;
const int minVelocity = 1;
const int carLaneInit = 2;
const double probFalling = 2/9;
global move : [0..1] init 0; // 0: car 1: pedestrian
formula ped_at_edge = ped_street_pos = 1 | ped_street_pos = streetLength;
formula car_at_end = car_street_pos = streetLength;
// check ped within [car_pos-velocity..car_pos], same lane
formula crash_straight = (car_lane_pos=ped_lane_pos & ped_street_pos>=car_street_pos-velocity & ped_street_pos<=car_street_pos);
// check ped street pos within [car_street_pos-velocity..car_street_pos], ped lane pos within [car_lane_pos-1..car_lane_pos]
formula crash_left = (switched_left & ped_lane_pos>=car_lane_pos-1 & ped_lane_pos<=car_lane_pos & ped_street_pos>=car_street_pos-velocity & ped_street_pos<=car_street_pos);
// check ped street pos within [car_street_pos-velocity..car_street_pos], ped lane pos within [car_lane_pos+1..car_lane_pos]
formula crash_right = (switched_right & ped_lane_pos>=car_lane_pos+1 & ped_lane_pos<=car_lane_pos & ped_street_pos>=car_street_pos-velocity & ped_street_pos<=car_street_pos);
label "crashed" = crash_straight | crash_left | crash_right;
label "maxedOut" = velocity=maxVelocity;
label "pedCrossed" = ped_lane_pos=lanes;
module car
switched_right : bool init false;
switched_left : bool init false;
car_street_pos : [0..streetLength] init 0;
car_lane_pos : [2..lanes-1] init carLaneInit;
velocity : [minVelocity..maxVelocity] init minVelocity;
// TODO
endmodule
module pedestrian
ped_street_pos : [0..streetLength] init floor(streetLength/4);
ped_lane_pos : [1..lanes] init 1;
fell_down : [0..2] init 0; // 1-2: getting up
[move] move=1 & fell_down=0 -> ((1-probFalling)/4): (ped_lane_pos'=min(lanes,ped_lane_pos+1)) & (move'=0) +
((1-probFalling)/4): (ped_lane_pos'=max(1,ped_lane_pos-1)) & (move'=0) +
((1-probFalling)/4): (ped_street_pos'=min(lanes,ped_street_pos+1)) & (move'=0) +
((1-probFalling)/4): (ped_street_pos'=max(1,ped_street_pos-1)) & (move'=0) +
(probFalling/4): (ped_lane_pos'=min(lanes,ped_lane_pos+1)) & (fell_down'=2) & (move'=0) +
(probFalling/4): (ped_lane_pos'=max(1,ped_lane_pos-1)) & (fell_down'=2) & (move'=0) +
(probFalling/4): (ped_street_pos'=min(lanes,ped_street_pos+1)) & (fell_down'=2) & (move'=0) +
(probFalling/4): (ped_street_pos'=max(1,ped_street_pos-1)) & (fell_down'=2) & (move'=0);
[getUp] move=1 & fell_down>0 -> 1: (fell_down'=fell_down-1) & (move'=0);
endmodule