Advertisement
Kredens234

damian ty pało

Jun 12th, 2022
2,443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.55 KB | None | 0 0
  1. xchessboard(1..8).
  2. ychessboard(1..8).
  3. posA1(1,1).
  4. step(1..8*8-1).
  5. posXY(X,Y) :- xchessboard(X), ychessboard(Y), not posA1(X,Y).
  6. moveTo(X1,Y1,X2,Y2) :- posXY(X1,Y1), posXY(X2,Y2), |X1-X2| = 1, |Y1-Y2| = 2.
  7. moveTo(X1,Y1,X2,Y2) :- posXY(X1,Y1), posXY(X2,Y2), |X1-X2| = 2, |Y1-Y2| = 1.
  8. 1 { position(I,X,Y) : posXY(X,Y) } 1 :- step(I).
  9. :- step(I), step(I+1), posXY(X1,Y1), posXY(X2,Y2), position(I,X1,Y1), position(I+1,X2,Y2), not  moveFromTo(X1,Y1,X2,Y2).
  10. :- step(I1-1), step(I2), I1 < I2, posXY(X,Y), position(I1,X,Y), position(I2,X,Y).
  11. position(1,2,1).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement