print("(c{:02d}x Int)".format(i), end=' ')
print("(c{:02d}y Int)".format(i), end=' ')
print("(c{:02d}w Int)".format(i), end=' ')
- print("(c{:02d}h Int)".format(i), end=' ')
+ print("(c{:02d}h Int)".format(i))
print(")")
# Preamble2
'\t(or '
'(and (= c{0:02d}w {1}) (= c{0:02d}h {2})) '
'(and (= c{0:02d}w {2}) (= c{0:02d}h {1}))'
- ')').format(i, w, h))
+ ')').format(i, w-1, h-1))
# Print the bounds of the coordinates
print((
# Print the non overlap with others
for j in range(1, 1+len(pc+rc)):
- print((
- '\t(or (= {0} {1})\n'
- '\t\t(> c{0:02d}x (+ c{1:02d}x c{1:02d}w)) '
- '(< (+ c{0:02d}x c{0:02d}w) c{1:02d}x)\n'
- '\t\t(> c{0:02d}y (+ c{1:02d}y c{1:02d}h)) '
- '(< (+ c{0:02d}y c{0:02d}h) c{1:02d}y)'
- ')').format(i, j))
+ if i != j:
+ print((
+ '\t(or \n'
+ '\t\t(> c{0:02d}x (+ c{1:02d}x c{1:02d}w)) '
+ '(< (+ c{0:02d}x c{0:02d}w) c{1:02d}x)\n'
+ '\t\t(> c{0:02d}y (+ c{1:02d}y c{1:02d}h)) '
+ '(< (+ c{0:02d}y c{0:02d}h) c{1:02d}y)'
+ ')').format(i, j))
# Print the PC distance to eachother
-for i, _ in enumerate(pc, 1):
- for j, _ in enumerate(pc, 1):
- print((
- '\t(or (= {0} {1})\n'
- '\t\t(> (- (/ (+ c{0:02d}x c{0:02d}w) 2) (/ (+ c{1:02d}x c{1:02d}w) 2)) {2})\n'
- '\t\t(> (- (/ (+ c{1:02d}x c{1:02d}w) 2) (/ (+ c{0:02d}x c{0:02d}w) 2)) {2})\n'
- '\t\t(> (- (/ (+ c{0:02d}y c{0:02d}h) 2) (/ (+ c{1:02d}y c{1:02d}h) 2)) {2})\n'
- '\t\t(> (- (/ (+ c{1:02d}y c{1:02d}h) 2) (/ (+ c{0:02d}y c{0:02d}h) 2)) {2})'
- ')').format(i, j, pd))
+#for i, _ in enumerate(pc, 1):
+# for j, _ in enumerate(pc, 1):
+# if i != j:
+# print((
+# '\t(or \n'
+# '\t\t(> (- (/ (+ c{0:02d}x c{0:02d}w) 2) '
+# '(/ (+ c{1:02d}x c{1:02d}w) 2)) {2})\n'
+# '\t\t(> (- (/ (+ c{1:02d}x c{1:02d}w) 2) '
+# '(/ (+ c{0:02d}x c{0:02d}w) 2)) {2})\n'
+# '\t\t(> (- (/ (+ c{0:02d}y c{0:02d}h) 2) '
+# '(/ (+ c{1:02d}y c{1:02d}h) 2)) {2})\n'
+# '\t\t(> (- (/ (+ c{1:02d}y c{1:02d}h) 2) '
+# '(/ (+ c{0:02d}y c{0:02d}h) 2)) {2})'
+# ')').format(i, j, pd))
# Print the constraint that they have to be connected to a ps
for i, _ in enumerate(rc, 1+len(pc)):
print('\t(or')
for j, _ in enumerate(pc, 1):
print((
- '\t\t(= c{0:02d}x (+ c{1:02d}x c{1:02d}w 1))\n'
- '\t\t(= (+ c{0:02d}x c{0:02d}w 1) c{1:02d}x)\n'
- '\t\t(= c{0:02d}y (+ c{1:02d}y c{1:02d}h 1))\n'
- '\t\t(= (+ c{0:02d}y c{0:02d}h 1) c{1:02d}y)'
- ).format(i, j))
+ '\t(not (or \n'
+ '\t\t(> c{0:02d}x (+ c{1:02d}x 1 c{1:02d}w)) '
+ '(< (+ c{0:02d}x c{0:02d}w) (- c{1:02d}x 1))\n'
+ '\t\t(> c{0:02d}y (+ c{1:02d}y 1 c{1:02d}h)) '
+ '(< (+ c{0:02d}y c{0:02d}h) (- c{1:02d}y 1))'
+ '))').format(i, j))
print('\t)')
# Close the and,benchmark parenthesis