% в клетке с той же координатой y ранение - корабль убит
kill(X,Y,4):-kl(kletka(pole(XX,Y),4)),kl(kletka(pole(XXX,Y),4)),
kl(kletka(pole(XXXX,Y),4)),
X<>XX,X<>XXX,X<>XXXX,XX<>XXX,XX<>XXXX,XXX<>XXXX,
min(X,XX,B),min(B,XXX,C),min(C,XXXX,Z),
max(X,XX,BB),max(BB,XXX,CC),max(CC,XXXX,ZZ),
XA=ZZ+1,XB=Z-1,YA=Y+1,YB=Y-1,
change(X,Y,9),change(X,YA,5),change(X,YB,5),
change(XX,Y,9),change(XX,YA,5),change(XX,YB,5),
change(XXX,Y,9),change(XXX,YA,5),change(XXX,YB,5),
change(XXXX,Y,9),change(XXXX,YA,5),change(XXXX,YB,5),
change(XA,Y,5),change(XA,YA,5),change(XA,YB,5),
change(XB,Y,5),change(XB,YA,5),change(XB,YB,5).
kill(_,_,_).
myhod:-print,
cursor(15,10),writef("X= "),cursor(16,10),writef("Y= "),
cursor(15,12),readint(X),cursor(16,12),readint(Y),
hod_my(X,Y).
%-----------------------------------------------------------------------
% вывод координатной сетки
axis:-cursor(0,0),writef(" Y Y"),
cursor(1,6),writef("0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9"),
cursor(2,5),writef("-------------------- --------------------"),
cursor(7,1),writef("X"),cursor(7,27),writef("X"),
cursor(3,3),writef("0|"),cursor(3,29),writef("0|"),
cursor(4,3),writef("1|"),cursor(4,29),writef("1|"),
cursor(5,3),writef("2|"),cursor(5,29),writef("2|"),
cursor(6,3),writef("3|"),cursor(6,29),writef("3|"),
cursor(7,3),writef("4|"),cursor(7,29),writef("4|"),
cursor(8,3),writef("5|"),cursor(8,29),writef("5|"),
cursor(9,3),writef("6|"),cursor(9,29),writef("6|"),
cursor(10,3),writef("7|"),cursor(10,29),writef("7|"),
cursor(11,3),writef("8|"),cursor(11,29),writef("8|"),
cursor(12,3),writef("9|"),cursor(12,29),writef("9|").
% конец игры
win:-not(kl(kletka(pole(_,_),-1))),not(kl(kletka(pole(_,_),-3))),
not(kl(kletka(pole(_,_),-2))),not(kl(kletka(pole(_,_),-4))),
cursor(15,10),writef(" "),
cursor(16,10),writef(" "),
cursor(15,15),writef("Victory!!!"),!.
win:-not(mykl(kletka(pole(_,_),-1))),not(mykl(kletka(pole(_,_),-3))),
not(mykl(kletka(pole(_,_),-2))),not(mykl(kletka(pole(_,_),-4))),
cursor(15,10),writef(" "),
cursor(16,10),writef(" "),
cursor(15,15),writef("Losses!!!"),!.
win:-cursor(15,10),writef(" "),
cursor(16,10),writef(" "),
cursor(15,15),writef("Next move"),
myhod,print,evmhod,myprint,win.
%-----------------------------------------------------------------------
% начало игры
start:-makewindow(1,7,15,"SEA BATTLE",0,0,25,60),
menu(1),
cursor(17,10),retractall(_).
menu(0):-!.
menu(1):-del1,del2,clearwindow,
cursor(15,10),writef("Build pole on auto <0>"),
cursor(16,10),writef("Using keyboard <1>"),cursor(17,10),readint(F),
cursor(15,10),writef(" "),
cursor(16,10),writef(" "),
cursor(17,10),writef(" "),
mybuild(F),myprint,
build,print,
axis,
win,
cursor(18,10),writef("Play again?(0/1)"),readint(N),
menu(N).
del1:-retract(kl(kletka(pole(_,_),_)),pole),fail.
del1.
del2:-retract(mykl(kletka(pole(_,_),_)),mypole),fail.
del2.
GOAL
start.
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.