Hello,
I am writing a prolog program that compares the positions of buildings.
The only fact I can use is west(building1, building2), which says that building 1 is immediately west of building 2. I have declared many of these for the two rows of buildings I am using.
I am having trouble with a rule called nextdoor(X,Y). Obviously, when I just put the west fact into the rule and test it with two buildings X Y, when X is west of Y, the rule comes out to true. But when I switch the assignment of buildings to the variables it doesn't work.
For example, if building 2 is immediately east of building 1, they are still next door, but I can not figure out how to make this come out to true using only the west(X, Y) fact.
I am only allowed to use the west facts, nothing else.
I'm assuming I need to add some "ands" in the rule and use another variable but I can not figure out how to structure it for life of me!
Any help would be greatly appreciated.
Thank you!