title: Depth First Search Algorithm Prolog
body: <p>I am hoping you could help me with this.</p>
  
  <p>I am trying to learn about Depth First search algorithm in Prolog and I have come across the following code</p>
  
  <pre><code>go(Start, Goal) :-
     empty_stack(Empty_been_list),
     stack(Start, Empty_been_list, Been_list),
     path(Start, Goal, Been_list).
  
  % path implements a depth first search in PROLOG
  
  % Current state = goal, print out been list
  path(Goal, Goal, Been_list) :-
      reverse_print_stack(Been_list).
  
  path(State, Goal, Been_list) :-
      mov(State, Next),
      % not(unsafe(Next)),
      not(member_stack(Next, Been_list)),
      stack(Next, Been_list, New_been_list),
      path(Next, Goal, New_been_list), !.
  
  reverse_print_stack(S) :-
      empty_stack(S).
  reverse_print_stack(S) :-
      stack(E, Rest, S),
      reverse_print_stack(Rest),
      write(E), nl.
  </code></pre>
  
  <p>I kind of understand what is going on, but I cant for the life of me find or invent some facts that I can use with it.</p>
  
  <p>Please help. Even if its a really simple set of facts, I just need somewhere to start</p>
  
  <p>Thank you in advance</p>