title: Turn Depth First Search into a Best-First (greedy) Search in prolog
body: <p>I am wanting to modify my depth first search to a best-first search.</p>
  
  <p>My depth first search is as follows</p>
  
  <pre><code>goal(fivet).
  
  move(onea,twoa).
  move(onea,twob).
  move(onea,twoc).
  move(onea,twod).
  move(twoa,threea).
  move(twoa,threeb).
  move(twoa,threec).
  move(threea,foura).
  move(threea,fourb).
  move(foura,fivea).
  move(fourb,fiveb).
  move(threeb,fourc).
  move(threeb,fourd).
  move(fourc,fivec).
  move(fourd,fived).
  move(threec,foure).
  move(threec,fourf).
  move(foure,fivee).
  move(fourf,fivef).
  move(twob,threed).
  move(twob,threee).
  move(twob,threef).
  move(threed,fourg).
  move(threed,fourh).
  move(fourg,fiveg).
  move(fourh,fiveg).
  move(threee,fouri).
  move(threee,fourj).
  move(fouri,fivei).
  move(fourj,fivej).
  move(threef,fourk).
  move(threef,fourl).
  move(fourk,fivek).
  move(fourl,fivel).
  move(twoc,threeg).
  move(twoc,threeh).
  move(twoc,threei).
  move(threeg,fourm).
  move(threeg,fourn).
  move(fourm,fivem).
  move(fourn,fiven).
  move(threeh,fouro).
  move(threeh,fourp).
  move(fouro,fiveo).
  move(fourp,fivep).
  move(threei,fourq).
  move(threei,fourr).
  move(fourq,fiveq).
  move(fourr,fiver).
  move(twod,threej).
  move(twod,threek).
  move(twod,threel).
  move(threej,fours).
  move(threej,fourt).
  move(fours,fives).
  move(fourt,fivet).
  move(threek,fouru).
  move(threek,fourv).
  move(fouru,fiveu).
  move(fourv,fivev).
  move(threel,fourw).
  move(threel,fourx).
  move(fourw,fivew).
  move(fourx,fivex).
  
  
  dfs(A, Path, Path) :- goal(A).
  
  dfs(A, Checked, Path) :-
      % try a move
      move(A, A2),
      % ensure the resulting state is new
      \+member(A2, Checked),
      % and that this state leads to the goal
      dfs(A2, [A2|Checked], Path).
  
  % query = dfs(onea, [], Path).
  </code></pre>
  
  <p>please excuse the long winded program, its a rather large search tree.</p>
  
  <p><img src="https://i.stack.imgur.com/xSdlJ.png" alt="Best-First search tree"></p>
  
  <p>I have given all the nodes a metric X.</p>
  
  <p>is it a simple process to change the above program from depth first to best-first?</p>
  
  <p>any help would be much appreciated.</p>
  
  <p>thank you </p>