1

I have a rule that generates the following

route(5,1,5,3) 
route(5,2,5,3) 
route(5,3,5,3) 
route(3,1,3,1) 
route(2,3,5,3) 
route(3,3,5,3) 
route(4,3,5,3) 
route(4,1,3,1) 
route(5,1,3,1) 
route(3,2,3,1) 
route(3,3,3,1) 
route(3,4,3,1) 
route(3,5,3,1)

in which the following part is a route starting at 5,1 and ending at 5,3

route(5,1,5,3) 
route(5,2,5,3) 
route(5,3,5,3)

in route(x1,y1,x2,y2)

  • x1 = x coordinate of first point
  • y1 = y coordinate of first point
  • x2 = x coordinate of second point
  • y2 = y coordinate of second point

I want to write a constraint so that these routes do not cross each other but I am not sure how to approach this problem. I would appreciate any help in this matter.

NTP
  • 4,338
  • 3
  • 16
  • 24

1 Answers1

1

I used the following rule to prevent crossing of routes.

(X',Y') = (X'',Y'') :- route(X,Y,X',Y'), route(X,Y,X'',Y'').
NTP
  • 4,338
  • 3
  • 16
  • 24
  • This is not a constraint but a rule. I am not sure your rule does what you intend. If you provide the program that generates the route/4 atoms it would be possible to test and extend your solution. – peschü Dec 02 '19 at 13:22