The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

61 lines
2.1 KiB

2 months ago
  1. // PRISM Model of a simple robot game
  2. // - A player - friendlyRobot - moves around and tries not to "crash" with another player - adversary Robot.
  3. // - friendlyRobot can choose the direction of movement.
  4. // - adversaryRobot should move in a circle counterclockwise on the grid, but has a probabilty to fail and move into the wrong direction.
  5. // - The movement of adversaryRobot is defined as a pseudo random movement with probabilty = 1/4 into one of the 4 possible directions.
  6. smg
  7. player friendlyRobot
  8. [e1], [w1], [n1], [s1]
  9. endplayer
  10. player adversaryRobot
  11. [e2], [w2], [n2], [s2], [middle]
  12. endplayer
  13. // 3x3 grid
  14. const int width = 2;
  15. const int height = 2;
  16. const int xmin = 0;
  17. const int xmax = width;
  18. const int ymin = 0;
  19. const int ymax = height;
  20. // probabilty to fail
  21. const double failProb = 1/10;
  22. const double notFailProb = 1-failProb;
  23. // definition of randomProb, this has to be 0.25 since it is the prob of go into one direction from the middle for the adverseryRobot
  24. const double randomProb = 1/4;
  25. global move : [0..1] init 0;
  26. //F__
  27. //___
  28. //__R
  29. label "crash" = x1=x2 & y1=y2;
  30. module robot1
  31. x1 : [0..width] init 0;
  32. y1 : [0..height] init 0;
  33. [e1] move=0 & x1<xmax -> (x1'=x1+1) & (move'=1);
  34. [w1] move=0 & x1>0 -> (x1'=x1-1) & (move'=1);
  35. [n1] move=0 & y1>0 -> (y1'=y1-1) & (move'=1);
  36. [s1] move=0 & y1<ymax -> (y1'=y1+1) & (move'=1);
  37. endmodule
  38. module robot2
  39. x2 : [0..width] init width;
  40. y2 : [0..height] init height;
  41. [e2] move=1 & x2<xmax & y2=ymax -> notFailProb : (x2'=x2+1) & (move'=0) + failProb : (y2'=y2-1) & (move'=0);
  42. [w2] move=1 & x2>0 & y2=0 -> notFailProb : (x2'=x2-1) & (move'=0) + failProb : (y2'=y2+1) & (move'=0);
  43. [n2] move=1 & x2=xmax & y2>0 -> notFailProb : (y2'=y2-1) & (move'=0) + failProb : (x2'=x2-1) & (move'=0);
  44. [s2] move=1 & x2=0 & y2<ymax -> notFailProb : (y2'=y2+1) & (move'=0) + failProb : (x2'=x2+1) & (move'=0);
  45. [middle] move=1 & x2=1 & y2=1 -> randomProb : (x2'=x2+1) & (move'=0) + randomProb : (x2'=x2-1) & (move'=0) + randomProb : (y2'=y2-1) & (move'=0) + randomProb : (y2'=y2+1) & (move'=0);
  46. endmodule