I need an algorithm that given a set of domino pieces, returns every possible end to the game.
I have already found this one, Prolog domino game, but it only adds pieces to the beggining of the set, so it doesn't give you every possible solution.
I replaced this [5-4, 4-3, 3-2, 2-1]
, with this [[5,4], [4,3], [3,2], [2,1]]
, and tried adding this line domino_order(In, X, [Out|[X,Y]]) :- select(Piece, In, Remaining), swap_or_not(Piece, [X,Y]), domino_order(Remaining, Y, Out).
, but it doesn't work.
writing down the detailed logic would lead to somewhat complex code. I suggest instead to have a quick check for validity, and let Prolog work out the insertion points.