title: Prolog domino game
body: <p>i'm making a game in prolog, with a given set of domino pieces, it should make a correct domino row using all the pieces in the initial set. we must use an inference system in which we must build the initial state and the final state like this:</p>
  
  <pre><code>       initial(dominos([[1,4],[2,3],[4,2]],[])).
           final(dominos([],[[1,4],[4,2],[2,3]])).
  </code></pre>
  
  <p>the first transtion is just pick one pice from the 1st list and put it into the 2nd list, but the next ones should verify if the 2nd number matches the 1st number of the piece to be put. i think i have the 2nd transition's head</p>
  
  <p>first transition:</p>
  
  <pre><code>transition(dominos(L,[]),A,dominos(L1,[A])):- select(A,L,L1). 
  </code></pre>
  
  <p>second transition:</p>
  
  <pre><code>transition(dominos(L,B),A,dominos(L1,[[X,Y]|[Y,_])):- select(B,L,L1).
  </code></pre>
  
  <p>how do i verify the conditions?</p>