• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Nov 14th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. /* --------------------------------------------------------------------- */
2.
3. display_info():-
4.     nl,
5.     write('Move (1:up, 2:right, 3:down, 4:left): ').
6.
7. display_new_coords():-
8.     write(' New coords: ['),
9.     write(X2_new),
10.     write(', '),
11.     write(Y2_new),
12.     write(']'),
13.     nl.
14.
15. get_destination_coords(X1, Y1, X2, Y2, Board):-
16.     get_cell(X1, Y1, Board, MovesCounter),
17.     X2 is X1,
18.     write('X1: '), write(X1), nl,
19.     Y2 is Y1,
20.     write('Y1: '), write(Y1), nl,
21.     write_info().
22.     read_move(X2, X2_new, Y2, Y2_new, MovesCounter),
23.     write('newX: '), write(X2_new), nl,
24.     write('newY: '), write(Y2_new), nl.
25.
26.
27. read_move(X2, X2_new, Y2, Y2_new, MovesCounter):-
29.     increment_coords(X2, Y2, X2_new, Y2_new, MovesCounter, Move),
30.     write_new_coords().
31.     /*
32.     for(I,1,MovesCounter),param(MovesCounter) do
33.         MovesCounter_new is MovesCounter-I+1,
34.         nl, write('Moves left: '), write(MovesCounter_new), nl,
36.         increment_coords(X2, X2_new_2, Y2, Y2_new_2, I, Move),
37.         X2_new is X2_new_2,
38.         Y2_new is Y2_new_2,
39.         write(' New coords: ['), write(X2_new), write(', '), write(Y2_new), write(']'), nl.
40.     */
41.
42. /* UP */
43. increment_coords(X2, Y2, X2_new, Y2_new, MovesCounter, Move):-
44.     Move =:= 1,
45.     write('olaa'),
46.     X2_new is X2-1,
47.     write('olaa'),
48.     X2_new >= 0,
49.     Y2_new is Y2,
51. /* LEFT */
52. increment_coords(X2, Y2, X2_new, Y2_new, MovesCounter, Move):-
53.     Move =:= 2,
54.     X2_new is X2,
55.     Y2_new is Y2+1,
56.     Y2_new < 8,
58. /* DOWN */
59. increment_coords(X2, Y2, X2_new, Y2_new, MovesCounter, Move):-
60.     Move =:= 3,
61.     X2_new is X2+1,
62.     X2_new < 8,
63.     Y2_new is Y2,
65. /* RIGHT */
66. increment_coords(X2, Y2, X2_new, Y2_new, MovesCounter, Move):-
67.     Move =:= 4,
68.     X2_new is X2,
69.     Y2_new is Y2-1,
70.     Y2_new >= 0,