fork(1) download
  1. :- set_prolog_flag(verbose,silent).
  2. :- prompt(_, '').
  3. :- use_module(library(readutil)).
  4.  
  5. goal_check([]).
  6. goal_check([[]|Xs]):-goal_check(Xs).
  7. goal_check([[X,X,X,X]|Xs]):-goal_check(Xs).
  8.  
  9. goal_search([[Old1,Now1]|Datas1]):-goal_check(Now1).
  10. goal_search([_|Datas1]):-goal_search(Datas1).
  11.  
  12. move_check([X,X,X,Y],[X,X,X],[Y]):-X\=Y.
  13. move_check([X,X,Y,Y2],[X,X],[Y,Y2]):-X\=Y.
  14. move_check([X,Y,Y2,Y3],[X],[Y,Y2,Y3]):-X\=Y.
  15. move_check([X,X,X],[X,X,X],[]).
  16. move_check([X,X,Y],[X,X],[Y]):-X\=Y.
  17. move_check([X,Y,Y2],[X],[Y,Y2]):-X\=Y.
  18. move_check([X,X],[X,X],[]).
  19. move_check([X,Y],[X],[Y]):-X\=Y.
  20. move_check([X],[X],[]).
  21.  
  22. move(Xs1,Res):-select(E1,Xs1,Xs2),
  23. move_check(E1,E1Next,MoveWator),
  24. select(E2,Xs2,Xs),
  25. append(E1Next,E2,E2Next),
  26. length(Ys,Len),
  27. Len<5,
  28. sort([E1Next,E2Next|Xs],Res).
  29.  
  30. search_all_move(Data1,Next):-member([Old1,Now1],Data1),move(Now1,Next).
  31.  
  32. main:-
  33. process,
  34.  
  35. process:-
  36. /* your code goes here */
  37. Test=[[[],[[1,2,2,2],[2,1,1,1],[],[]]]],
  38. setof(E1,search_all_move(Test,E1),Test2),
  39. write(Test2),
  40.  
  41. :- main.
Success #stdin #stdout #stderr 0.04s 7228KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Warning: /home/z8Sq2S/prog:9:
	Singleton variables: [Old1,Datas1]
Warning: /home/z8Sq2S/prog:30:
	Singleton variables: [Old1]
Warning: /home/z8Sq2S/prog:43:
	Goal (directive) failed: user:main
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit