Rotations in Prolog

77 Views Asked by At

I have started a tetris-like program in prolog. I've defined the initial pieces without rotations or movements to the right (these are the only 2 options I want in my program).

% Definir o tamanho do tabuleiro
n(4).
m(4).

% Definir as peças
peca(i, [[1,1],[1,2],[1,3],[1,4]]).
peca(s, [[1,1],[1,2],[2,2],[2,3]]).
peca(o, [[1,1],[2,1],[2,2],[2,3]]).
peca(t, [[1,2],[2,1],[2,2],[2,3]]).


%Definir as rotações
nrot(NROT) :-
    NROT >= 0,
    NROT =< 3.

ndir(NDIR) :-
    NDIR >= 0.

%Definir peça com rotação
peca(i, [[1,1],[1,2],[1,3],[1,4]]):-
    NROT = 0,
    NDIR = 0.
    

n is width, m is height, peca are the pieces that consists in an atom and the coordinates of the piece if not moved. nrot is the number of 90 degrees rotations clockwise defined as an integer that will be given as input. ndir is the number of blocks i want my piece to go to the right defined as an integer that will be given as input. my question is how can i make the coordinates change according nrot and ndir

0

There are 0 best solutions below