Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. (define (domain lightup)
  2. ; (:requirements :adl :strips)
  3. (:requirements :adl)
  4. (:types
  5. xpos ;; x positions in the grid *DO NOT REMOVE*
  6. ypos ;; y positions in the grid *DO NOT REMOVE*
  7. num ;; numbers from 0 to 4 to count the number of light bulbs
  8. )
  9.  
  10. (:predicates
  11. ; You may, or may not, use / modify / remove any one of the following
  12. ; predicates:
  13.  
  14. ;; n2 = n1 + 1
  15. (increment ?n1 ?n2 - num)
  16.  
  17. ;; (?x1, ?y1) is (horizontally or vertically) adjacent to (?x2, ?y2)
  18. (adjacent ?x - xpos ?y - ypos ?x2 - xpos ?y2 - ypos)
  19.  
  20. ;; ?x2 is right of ?x1
  21. (right ?x1 ?x2 - xpos)
  22.  
  23. ;; ?y2 is below of ?y1
  24. (below ?y1 ?y2 - ypos)
  25.  
  26. ;; cell (?x, ?y) is lit-up
  27. (lit ?x - xpos ?y - ypos)
  28.  
  29. ;; cell (?x, ?y) is black
  30. (black ?x - xpos ?y - ypos)
  31.  
  32. ;; ?n many light bulbs are vertically or horizontally adjacent to (?x, ?y)
  33. ;; (may be only defined for the relevant black cells)
  34. (surrounded ?x - xpos ?y - ypos ?n - num)
  35.  
  36. ; TODO (optional): additional predicates go in here
  37. (decrement ?n1 ?n2 - num)
  38.  
  39. (left ?x1 ?x2 - xpos)
  40.  
  41. (up ?y1 ?y2 - ypos)
  42.  
  43. (bulb ?x - xpos ?y - ypos)
  44.  
  45. (inbetweenX ?x1 - xpos ?x - xpos ?x2 - xpos)
  46.  
  47. (inbetweenY ?y1 - ypos ?y - ypos ?y2 - ypos)
  48.  
  49. )
  50.  
  51. (:action place-bulb ; * DO NOT CHANGE THE NAME *
  52. :parameters (?x - xpos ?y - ypos) ; * DO NOT MODIFY THE PARAMETER LIST *
  53. :precondition (and
  54. (not (lit ?x ?y))
  55. (not (black ?x ?y))
  56. ; (or (forall (?a - xpos)
  57. ; (and (right ?x ?a) (not (bulb ?a ?y)) (not (black ?a ?y)))
  58. ; )
  59. ; (forall (?a - xpos)
  60. ; (and
  61. ; (right ?x ?a)
  62. ; (bulb ?a ?y)
  63. ; (exists (?z - xpos) (and (black ?z ?y) (inbetweenX ?x ?z ?a)))
  64. ; )
  65. ; )
  66. ; )
  67. ; (or (forall (?a - xpos)
  68. ; (and (left ?x ?a) (not (bulb ?a ?y)) (not (black ?a ?y)))
  69. ; )
  70. ; (forall (?a - xpos)
  71. ; (and
  72. ; (left ?x ?a)
  73. ; (bulb ?a ?y)
  74. ; (exists (?z - xpos) (and (black ?z ?y) (inbetweenX ?a ?z ?x)))
  75. ; )
  76. ; )
  77. ; )
  78. ; (or (forall (?a - ypos)
  79. ; (and (up ?y ?a) (not (bulb ?x ?a)) (not (black ?x ?a)))
  80. ; )
  81. ; (forall (?a - ypos)
  82. ; (and
  83. ; (up ?y ?a)
  84. ; (bulb ?x ?a)
  85. ; (exists (?z - ypos) (and (black ?x ?z) (inbetweenY ?y ?z ?a)))
  86. ; )
  87. ; )
  88. ; )
  89. ; (or (forall (?a - ypos)
  90. ; (and (below ?y ?a) (not (bulb ?x ?a)) (not (black ?x ?a)))
  91. ; )
  92. ; (forall (?a - ypos)
  93. ; (and
  94. ; (below ?y ?a)
  95. ; (bulb ?x ?a)
  96. ; (exists (?z - ypos) (and (black ?x ?z) (inbetweenY ?a ?z ?y)))
  97. ; )
  98. ; )
  99. ; )
  100.  
  101. )
  102. :effect (and
  103. (lit ?x ?y)
  104. (bulb ?x ?y)
  105. (forall (?a - xpos)
  106. (when (or
  107. ; for right side
  108. (and (right ?x ?a) (not (exists (?z - xpos) (and (right ?a ?z) (black ?z ?y)) )) )
  109. ; (and (right ?x ?a) (exists (?z1 - xpos) (and (right ?a ?z1) (black ?z1 ?y) (not (exists (?z2 - xpos) (and (left ?z1 ?z2) (right ?x ?z2) (black ?z2 ?y)))))) )
  110. ; for left side
  111. (and (left ?x ?a) (not (exists (?z - xpos) (and (left ?a ?z) (black ?z ?y)) )) )
  112. ; (and (left ?x ?a) (exists (?z1 - xpos) (and (left ?a ?z1) (black ?z1 ?y) (not (exists (?z2 - xpos) (and (right ?z1 ?z2) (left ?x ?z2) (black ?z2 ?y)))))) )
  113. )
  114. (lit ?a ?y)
  115. )
  116. )
  117. (forall (?a - ypos)
  118. (when (or
  119. ; for up side
  120. (and (up ?y ?a) (not (exists (?z - ypos) (and (up ?a ?z) (black ?x ?z)) )) )
  121. ; (and (up ?y ?a) (exists (?z1 - ypos) (and (up ?a ?z1) (black ?x ?z1) (not (exists (?z2 - ypos) (and (below ?z1 ?z2) (up ?y ?z2) (black ?x ?z2)))))) )
  122. ; for below side
  123. (and (below ?y ?a) (not (exists (?z - ypos) (and (below ?a ?z) (black ?x ?z)) )) )
  124. ; (and (below ?y ?a) (exists (?z1 - ypos) (and (below ?a ?z1) (black ?x ?z1) (not (exists (?z2 - ypos) (and (up ?z1 ?z2) (below ?y ?z2) (black ?x ?z2)))))) )
  125. )
  126. (lit ?x ?a)
  127. )
  128. )
  129.  
  130. )
  131.  
  132. )
  133. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement