Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. package ca.mcgill.ecse.fairtracks.queries
  2.  
  3. import "http://www.mcgill.ca/ecse/fairtracks/FairtracksDsl"
  4.  
  5. /****************************/
  6. //StaticObject Constraints
  7. /****************************/
  8.  
  9. //No.1 From checklist
  10. //Check if the object is out of the field
  11. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  12. severity = "error",
  13. message = "Object out of court",
  14. key = {o1})
  15. pattern outOfField(o1 : FTStaticObject) {
  16. find lowerBoundOfTrack(o1, low);
  17. find upperBoundOfTrack(o1, high);
  18. FTStaticObject.lengthX(o1, lengthx);
  19. FTStaticObject.lengthY(o1, lengthy);
  20. FTStaticObject.position.LLx(o1, llx);
  21. FTStaticObject.position.LLy(o1, lly);
  22. check( (llx < low) || (lly < low) || (llx + lengthx) > high || (lly + lengthy) > high);
  23. }
  24.  
  25.  
  26.  
  27. /****************************/
  28. //Player Constraints
  29. /****************************/
  30.  
  31. //No.2 from checklist
  32. //Player has to start from one of the starting corner
  33. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  34. severity = "error",
  35. message = "Player does not start at correct location",
  36. key = {player1})
  37. pattern incorrectStartPlayer(player1 : FTPlayer){
  38. neg find startingPositionPlayer(player1);
  39. }
  40. //Helper pattern to see if player has the correct starting position
  41. private pattern startingPositionPlayer(player1 : FTPlayer){
  42. find lowerBoundOfTrack(player1, low);
  43. find upperBoundOfTrack(player1, high);
  44. FTPlayer.position.LLx(player1, llx);
  45. FTPlayer.position.LLy(player1, lly);
  46. check((llx == low && lly == low) || (llx == high && lly == low) || (llx == high && lly == high) || (llx == low && lly == high));
  47. }
  48.  
  49. //No.3 from checklist
  50. //Check if two player has the same role
  51. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  52. severity = "error",
  53. message = "duplicate role",
  54. key = {player1, player2})
  55. pattern duplicatePlayerRole(player1 : FTPlayer, player2 : FTPlayer, commonRole : FTRole) {
  56. FTPlayer.role(player1, commonRole);
  57. FTPlayer.role(player2, commonRole);
  58. player1 != player2;
  59. }
  60.  
  61. //No.4 from checklist
  62. //Must start from different position
  63. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  64. severity = "error",
  65. message = "duplicate starting corner",
  66. key = {player1, player2})
  67. pattern duplicateStartPosition(player1 : FTPlayer, player2 : FTPlayer){
  68. FTPlayer.position.LLx(player1,samex);
  69. FTPlayer.position.LLx(player2,samex);
  70. FTPlayer.position.LLy(player1,samey);
  71. FTPlayer.position.LLy(player2,samey);
  72. player1 != player2;
  73. }
  74.  
  75. //No.5 from checklist
  76. //To be discussed
  77.  
  78. //No.6 from checklist
  79. //Player who can pickup has to have pickup color associated
  80. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  81. severity = "error",
  82. message = "No Pickable Obstacle color",
  83. key = {player1})
  84. pattern noPickupColor(player1: FTPlayer){
  85. FTPlayer.canPickUpObject(player1, true);
  86. neg find playerByColor(player1);
  87. }
  88. //Helper pattern to check if player has any pickable color
  89. pattern playerByColor(p1 : FTPlayer){
  90. FTPlayer.pickUpColor.color(p1,::White);
  91. } or {
  92. FTPlayer.pickUpColor.color(p1,::Red);
  93. } or {
  94. FTPlayer.pickUpColor.color(p1,::Blue);
  95. } or {
  96. FTPlayer.pickUpColor.color(p1,::Yellow);
  97. }
  98.  
  99.  
  100. /****************************/
  101. //Zone Constraints
  102. /****************************/
  103.  
  104. //No.7 from checklist
  105. //Removed from the new model
  106.  
  107. //No.8 from checklist
  108. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  109. severity = "error",
  110. message = "Incorrect containment shape",
  111. key = {zone1, zone2})
  112. pattern incorrectContainShape(zone1 : FTZone, zone2 : FTZone){
  113. FTZone.contains(zone1, zone2);
  114. FTZone.position.LLx(zone1, llx1);
  115. FTZone.position.LLy(zone1, lly1);
  116. FTZone.position.LLx(zone2, llx2);
  117. FTZone.position.LLy(zone2, lly2);
  118. FTZone.lengthX(zone1, lengthx1);
  119. FTZone.lengthY(zone1, lengthy1);
  120. FTZone.lengthX(zone2, lengthx2);
  121. FTZone.lengthY(zone2, lengthy2);
  122. check(llx1 > llx2 || lly1 > lly2 || (llx2 + lengthx2) > (llx1 + lengthx1) || (lly2 + lengthy2) > (lly1 + lengthy1) );
  123. }
  124. //No.9 from checklist
  125. //To be discussed
  126.  
  127. //No.10 from checklist
  128. //TODO
  129.  
  130. //No.11 from checklist
  131. //TODO
  132.  
  133. //No.12 from checklist
  134. //To be discussed
  135.  
  136. //No.13 from checklist
  137. //TODO To be discussed
  138. //EVERY ZONE NEEDS AN adj zone unless ziplined
  139. //pattern noAdjAllowedZone(zone1 : FTZone){
  140. // FTZone.disallowedPlayers(zone1, player1);
  141. // FTZone.isAdjacentTo(zone1, zone2);
  142. //}
  143. //
  144. //pattern disallowedZoneForPlayer(player1, zone1){
  145. // FTZone.disallowedPlayers(zone1,player1);
  146. //}
  147.  
  148. //No.14 from checklist
  149. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  150. severity = "error",
  151. message = "Circular Zone containment",
  152. key = {z1, z2})
  153. pattern circularZoneContainment(z1 : FTZone, z2 : FTZone){
  154. find contains(z2,z1);
  155. find contains+(z1,z2);
  156. z1 != z2;
  157. }
  158.  
  159. //No.15 from checklist
  160. @Constraint(targetEditorId = "ca.mcgill.ecse.fairtracks.FairtracksDsl",
  161. severity = "error",
  162. message = "Self containment",
  163. key = {z1, z2})
  164. pattern noSelfContain(z1 : FTZone, z2 : FTZone){
  165. FTZone.contains(z1, z2);
  166. z1 == z2;
  167. }
  168.  
  169.  
  170. /****************************/
  171. //Obstacles Constraints
  172. /****************************/
  173.  
  174.  
  175. //No.23 from checklist with concrete value
  176. //@Constraint(targetEditorId = "org.eclipse.emf.ecore.presentation.ReflectiveEditorID",
  177. // severity = "error",
  178. // message = "The obs close to corner",
  179. // key = {o1})
  180. //pattern obstacleCloseToCorner(o1 : FTObstacle){
  181. // find lowerBoundOfTrack(o1, low);
  182. // FTObstacle.LLx(o1, llx1);
  183. // check(llx1 < low+2);
  184. //} or {
  185. // find lowerBoundOfTrack(o1, low);
  186. // FTObstacle.LLy(o1, lly1);
  187. // check(lly1 < low+2);
  188. //} or {
  189. // find upperBoundOfTrack(o1, high);
  190. // FTObstacle.URx(o1, urx1);
  191. // check(urx1 > high-2);
  192. //} or {
  193. // find upperBoundOfTrack(o1, high);
  194. // FTObstacle.URy(o1, ury1);
  195. // check(ury1 > high-2);
  196. //}
  197.  
  198. //////////////////////////////
  199. //Zipline Constraints
  200. //////////////////////////////
  201.  
  202. //No.24 from checklist
  203. pattern identicalPositionZipline(zipline : FTZipline) {
  204. FTZipline.lengthX(zipline, lengthx);
  205. FTZipline.lengthY(zipline, lengthy);
  206. check(lengthx == 0 && lengthy == 0);
  207. }
  208.  
  209. /****************************/
  210. //Helper patterns
  211. /****************************/
  212. private pattern upperBoundOfTrack(o1 : FTStaticObject, high : java Integer ) {
  213. Fairtracksmodel.staticObjects(fairtrack,o1);
  214. Fairtracksmodel.boardUpperBound(fairtrack, high);
  215. }
  216. private pattern lowerBoundOfTrack(o1 : FTStaticObject, low : java Integer ) {
  217. Fairtracksmodel.staticObjects(fairtrack,o1);
  218. Fairtracksmodel.boardLowerBound(fairtrack, low);
  219. }
  220. private pattern contains(z1 : FTZone, z2 : FTZone){
  221. FTZone.contains(z1, z2);
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement