• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest May 19th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. komp(symbol,symbol)
2. clauses
3. z(1,1,"-"). z(1,2,"-"). z(1,3,"-").
4. z(2,1,"-"). z(2,2,"-"). z(2,3,"-").
5. z(3,1,"-"). z(3,2,"-"). z(3,3,"-").
6.
7. gamer(1,x). gamer(0,o). komp(x,o). komp(o,x).
8.
9. hod(0,S,_):- blok(S,S),!,kartinka,write("Вы проиграли!").
10. hod(0,S,C):- blok(S,C),!,kartinka,hod(1,C,S).
11. hod(0,S,C):- retract(z(2,2,"-")),!,assert(z(2,2,S)),
12.   kartinka,hod(1,C,S).
13. hod(0,S,C):- z(R,St,"-"), (R+St) mod 2=0,retract(z(R,St,"-")),!,
14.   assert(z(R,St,S)),kartinka,hod(1,C,S).
15. hod(0,S,C):- retract(z(R,St,"-")),!,assert(z(R,St,S)),
16.   kartinka,hod(1,C,S).
17. hod(1,C,S):- z(_,_,"-"),write("Ходите:","по строке (от 1 до 3) - "),
18.   readint(R),R>0,R<4,write("по столбцу (от 1 до 3) - "),
20.   assert(z(R,St,C)),hod(0,S,C).
21. hod(_,_,_):- not(z(_,_,"-")),nl,write("Ничья!").
22.
23. blok(S,C):- z(N1,St,C),z(N2,St,C),N1<>N2,
24.   retract(z(N3,St,"-")),!,assert(z(N3,St,S));
25.   z(R,N1,C),z(R,N2,C),N1<>N2,retract(z(R,N3,"-")),!,
26.   assert(z(R,N3,S));
27.   z(I,I1,C),I=I1,z(J,J1,C),J=J1,I<>J,z(K,K1,"-"),K=K1,
28.   retract(z(K,K1,"-")),!,assert(z(K,K1,S));
29.   z(I,J,C),I+J=4,z(N,K,C),N<>I,N+K=4,z(M,L,"-"),M+L=4,
30.   retract(z(M,L,"-")),!,assert(z(M,L,S)).
31.
32.       kartinka:-z(1,1,S1),z(1,2,S2),z(1,3,S3),
33.         z(2,1,S4),z(2,2,S5), z(2,3,S6),
34.         z(3,1,S7),z(3,2,S8),z(3,3,S9),!,
35.   write("Ход компьютера."),nl,nl,
36.   write(S1,"|",S2,"|",S3),nl,
37.   write("------"),nl,
38.   write(S4,"|",S5,"|",S6),nl,
39.   write("------"),nl,
40.   write(S7,"|",S8,"|",S9),nl,nl.
41.
42.
43. goal
44. write("Кто ходит первым?? (1 - я, 0 - противник) "),