Advertisement
Guest User

Untitled

a guest
May 1st, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. link2(A,Colour,B) :- link(A,Colour,B).
  2. link2(A,Colour,B) :- link(B,Colour,A).
  3.  
  4. %next we define in what order the colours can be
  5. colourorder(red,brown).
  6. colourorder(brown,yellow).
  7. colourorder(yellow,red).
  8.  
  9. %then we create a predicate to run through the maze
  10. route(A,FirstColour,A,List) :-
  11. %link2(A,FirstColour,B),
  12. write("completed"),
  13. append([A],List,FinalList).
  14. write(FinalList).
  15.  
  16. route(A,FirstColour,B,Lists) :-
  17. link2(A,FirstColour,X),
  18. colourorder(FirstColour,SecondColour),
  19. %+member(A,Lists),
  20. %append(A,Lists,VisitedList),
  21. route(X,SecondColour,B,VisitedList).
  22.  
  23. %finally we create maze to run with route with 'start' as the start point and g as the end.
  24. %it then output the list
  25.  
  26. maze(Start) :-
  27. route(start,red,g,Start).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement