このディレクトリの索引

#  I'm making META-FORMS game in prolog
#  
#  The game consists in pieces and clues. I have a border and clues to restrict the places where I can put the pieces in border.
#  
#  Board: the board consist in a matrix 3x3
#  
#   Top:    Top/left       top/middle       top/right
#   center: center/left    center/middle    center/right
#   bottom: bottom/left    bottom/middle    bottom/right
#  Pieces example: piece(triangle, blue). -> A blue triangle ;
#  
#  Clue example: put(piece(square, yellow), top, right, Board). -> this is a direct clue telling me that I must put one square yellow on the top right position of the board.
#  
#  This is the code for the basic examples:
#  
#  put(P, top, left, [P,_,_,_,_,_,_,_,_]).
#  put(P, top, middle, [_,P,_,_,_,_,_,_,_]).
#  put(P, top, right, [_,_,P,_,_,_,_,_,_]).
#  put(P, center, left, [_,_,_,P,_,_,_,_,_]).
#  put(P, center, middle, [_,_,_,_,P,_,_,_,_]).
#  put(P, center, right, [_,_,_,_,_,P,_,_,_]).
#  put(P, bottom, left, [_,_,_,_,_,_,P,_,_]).
#  put(P, bottom, middle, [_,_,_,_,_,_,_,P,_]).
#  put(P, bottom, right, [_,_,_,_,_,_,_,_,P]).
#  In this advance level I have this input:
#  
#  matrixNeg(piece(triangle, blue),
#            [(top, right),
#             (center, middle),
#             (center, right),
#             (bottom, left),
#             (bottom, middle),
#             (bottom, right)],
#            Board).
#  First I recieve a piece, then a border with positions I CAN'T put the piece, then the game border to put it.
#  
#  I can't figure it out how can I do this. How can I, from restricted positions on the first boarder, make available the other position on the game boarder,
#  

put(P, top, left, [_,P2,P3,P4,P5,P6,P7,P8,P9],[P,P2,P3,P4,P5,P6,P7,P8,P9]).
put(P, top, middle, [P1,_,P3,P4,P5,P6,P7,P8,P9],[P1,P,P3,P4,P5,P6,P7,P8,P9]).
put(P, top, right, [P1,P2,_,P4,P5,P6,P7,P8,P9],[P1,P2,P,P4,P5,P6,P7,P8,P9]).
put(P, center, left, [P1,P2,P3,_,P5,P6,P7,P8,P9],[P1,P2,P3,P,P5,P6,P7,P8,P9]).
put(P, center, middle, [P1,P2,P3,P4,_,P6,P7,P8,P9],[P1,P2,P3,P4,P,P6,P7,P8,P9]).
put(P, center, right, [P1,P2,P3,P4,P5,_,P7,P8,P9],[P1,P2,P3,P4,P5,P,P7,P8,P9]).
put(P, bottom, left, [P1,P2,P3,P4,P5,P6,_,P8,P9],[P1,P2,P3,P4,P5,P6,P,P8,P9]).
put(P, bottom, middle, [P1,P2,P3,P4,P5,P6,P7,_,P9],[P1,P2,P3,P4,P5,P6,P7,P,P9]).
put(P, bottom, right, [P1,P2,P3,P4,P5,P6,P7,P8,_],[P1,P2,P3,P4,P5,P6,P7,P8,P]).

matrixNeg(Element,[],Board,Board).
matrixNeg(Element,[(Position_1,Position_2)|R],Board_1,Board) :-
        put(Element,Position_1,Position_2,Board_1,Board_2),
        matrixNeg(Element,R,Board_2,Board).