data_Fishka(13,X3,Y3,color_Black),Num3=(Gx-X3)*(Gx-X3)+(Gy-Y3)*(Gy-Y3),
data_Fishka(14,X4,Y4,color_Black),Num4=(Gx-X4)*(Gx-X4)+(Gy-Y4)*(Gy-Y4),
data_Fishka(15,X5,Y5,color_Black),Num5=(Gx-X5)*(Gx-X5)+(Gy-Y5)*(Gy-Y5),
data_Fishka(16,X6,Y6,color_Black),Num6=(Gx-X6)*(Gx-X6)+(Gy-Y6)*(Gy-Y6),
data_Fishka(17,X7,Y7,color_Black),Num7=(Gx-X7)*(Gx-X7)+(Gy-Y7)*(Gy-Y7),
data_Fishka(18,X8,Y8,color_Black),Num8=(Gx-X8)*(Gx-X8)+(Gy-Y8)*(Gy-Y8),
data_Fishka(19,X9,Y9,color_Black),Num9=(Gx-X9)*(Gx-X9)+(Gy-Y9)*(Gy-Y9),
Num=Num1+Num2+Num3+Num4+Num5+Num6+Num7+Num8+Num9-NumS+NumF,!.
goal_Comp(7,7).
goal_Comp(8,8).
goal_Comp(8,7).
goal_Comp(7,8).
goal_Comp(7,6).
goal_Comp(6,7).
goal_Comp(8,6).
goal_Comp(6,8).
goal_Comp(6,6).
% Финальные расстановки
fin_States:data_Fishka(_,8,7,color_Black),
not(data_Fishka(_,8,8,_)),
retractall(possible_Move(_,_),db),
assert(possible_Move([8,7,8,8],0),db),!.
fin_States:data_Fishka(_,7,8,color_Black),
not(data_Fishka(_,8,8,_)),
retractall(possible_Move(_,_),db),
assert(possible_Move([7,8,8,8],0),db),!.
fin_States:data_Fishka(_,7,7,color_Black),
not(data_Fishka(_,8,7,_)),
retractall(possible_Move(_,_),db),
assert(possible_Move([7,7,8,7],0),db),!.
fin_States:data_Fishka(_,7,7,color_Black),
not(data_Fishka(_,7,8,_)),
retractall(possible_Move(_,_),db),
assert(possible_Move([7,7,7,8],0),db),!.
fin_States:data_Fishka(_,6,6,color_Black),
data_Fishka(_,6,7,_),
not(data_Fishka(_,6,8,_)),
retractall(possible_Move(_,_),db),
assert(possible_Move([6,6,6,8],0),db),!.
fin_States:data_Fishka(_,6,6,color_Black),
data_Fishka(_,7,6,_),
not(data_Fishka(_,8,6,_)),
retractall(possible_Move(_,_),db),
assert(possible_Move([6,6,8,6],0),db),!.
fin_States.
% Начало игры
lets_Go(Win) :draw_Field(Win), % Прорисовка сетки
set_Fishka_Start, % Установка фишек в начальное положение
draw_Fishka(Win), % Прорисовка фишек
win_Invalidate(Win),!.
% Прорисовка поля
draw_Field(Win) :Field=pict_GetFromRes(idb_field),
pict_Draw(Win,Field,pnt(1,1),rop_SrcCopy),!.
% Установка фишек в начальное положение
set_Fishka_Start :% Запоминание координат фишек в базе данных
assert(data_Fishka(11,1,1,color_Black),db),assert(data_Fishka(12,1,2,color_Black),db),
assert(data_Fishka(13,1,3,color_Black),db),assert(data_Fishka(14,2,1,color_Black),db),
assert(data_Fishka(15,2,2,color_Black),db),assert(data_Fishka(16,2,3,color_Black),db),
assert(data_Fishka(17,3,1,color_Black),db),assert(data_Fishka(18,3,2,color_Black),db),
assert(data_Fishka(19,3,3,color_Black),db),
assert(data_Fishka(21,6,6,color_White),db),assert(data_Fishka(22,6,7,color_White),db),
assert(data_Fishka(23,6,8,color_White),db),assert(data_Fishka(24,7,6,color_White),db),
assert(data_Fishka(25,7,7,color_White),db),assert(data_Fishka(26,7,8,color_White),db),
assert(data_Fishka(27,8,6,color_White),db),assert(data_Fishka(28,8,7,color_White),db),
assert(data_Fishka(29,8,8,color_White),db),!.
% Прорисовка фишек
draw_Fishka(Win) :data_Fishka(_,Px,Py,Clr),
X = (Px-1)*33+2,
Y = (Py-1)*33+2,
draw_Fishka_Icon(Win,X,Y,Clr),
fail.
draw_Fishka(_) :- !.
draw_Fishka_Icon(Win,X,Y,color_White) :- draw_Icon(Win,X,Y,idi_fishka_white).
draw_Fishka_Icon(Win,X,Y,color_Black) :- draw_Icon(Win,X,Y,idi_fishka_black).
draw_Selected_Fishka_Icon(Win,Px,Py) :X = (Px-1)*33+2, Y = (Py-1)*33+2,
draw_Icon(Win,X,Y,idi_fishka_white_selected), !.
% Нахождение позиции по координатам
find_Position(pnt(X,Y),Px,Py) :- Px = X div 33 + 1, Py = Y div 33 + 1, !.
members([X1,Y1],[X1,Y1|_]):-!. % Вхождение двух элементов в список
members(XY,[_,_|Tail]):-members(XY,Tail).
concat_List([],Ys,Ys):-!. % Соединение двух списков
concat_List([X,Y|Xs],Ys,[X,Y|Zs]):-concat_List(Xs,Ys,Zs).
reverse_List([],[]):-!. %реверс списка
reverse_List([H1,H2|T],L):-reverse_List(T,RT),concat_List(RT,[H1,H2],L).
%BEGIN_WIN Task Window
/***************************************************************************
Event handling for Task Window
***************************************************************************/
PREDICATES
task_win_eh : EHANDLER
my_err_handler : ERRHANDLER
rect_Conv_Plus(rct,integer,integer,rct)
CONSTANTS
%BEGIN Task Window, CreateParms, 18:04:24-7.9.2003, Code automatically updated!
task_win_Flags = [wsf_DlgBorder,wsf_DlgBorder,wsf_TitleBar,wsf_Close,wsf_Minimize]
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.