.


:




:

































 

 

 

 


ALO




, AL0, Prolog, 22.4. . AL0; , ALO, , . AND/OR {. 13); AND/OR, , (. 15).



II. Prolog


22.4. Advice Language

Advice Language %

i , ,
% Advice Language
:- opl 200, xfy, [:,::].
:- op<220,xfy,..).
:- op{ 185, ix, if).
:- op[ 190, Hfx, then).
:- op(1ES0, xfy, or).
:- op(160, xfy, and).
:- op (140, fx, notj.
playgame! Pos):- % Pos

playgame! Pos, nil). %

playgame! , ForcingTree): -show! Pos),

(end_of_game(Pos), % ?

writef 'End of game'), nl,!

playmove(Pos, ForcingTree, Posl, ForcingTreel),!, playgame! Posl, ForcingTreel)

% playmove(Pos, Move..FTreel, Posl, FTreel):-

side(Pos, w)r % ,

%

legalmove.(Pos, Move, Posl),

showmove(Move). I , playmove(Pos, FTree, Posl, FTreel):-

side(Pos, b),

write('Your move: '),

read(Move),

(legalmove (Pos, Move, Posl), subtree,- FTree, Move, FTreel),! %

write [ 'Illegal move'), nl,
playmove(Pos, FTree, Posl, FTreel)
).
: ,
playmove(Pos, nil, Posl, FTreel):-
side(Pos, w),
resetdepth! POS, POSOI, % PosO - Pos

%
strategy! PosO, FTree), \, %

playmove(PosO, FTree, Posl, FTreel).

% , Move

subtree! FTrees, Move, FTreel:-

member,- (Move.. FTree, FTtees },!. subtree[_, _, nil).

strategy! Pos, ForcingTree):- % ? Pos Rule;: if Condition then AdviceList, %

% no holds! Condition, Pos, _),'., % Pos member! AdviceUame, AdviceList), %

nl, write('Trying1!, write! AdviceHame),

satisfiable{ AdviceName, Pos, ForcingTree),!. % AdviceHame

% Pos satisfiable(AdviceKame, Pos, FTree):-

advice! AdviceKame, Advice), % sat! Advice, Pos, Pos, FTree). % sat

s ,


22.



sat(Advice, Pos, RootPos, FTcee):-

holdinggoal(Advice, HG),

holds[ HG, Pos, RootPosI, %

%

satl(Advice, Pos, RootPos, FTree). Satl{ Advice, POS, Root.Pos, nil):-

bettergoaK Advice, BG),

holds[ BG, POS, RootPos),!. i satl(Advice, Pos, RootPos, Move..FTrees):-

side[ Pos, w),!, * ,

usmoveconstrl Advice, UMC),

move[ UMC, Pos, Move, Posl), %

sat( Advice, Posl, RootPos, FTrees). Satl(Advice, Pos, RootPos, FTrees}:-

side I Pos, b),!, i ,

themmoveconstr(Advice, TMC),

bagof(Move..Posl, move(TMC, Pos, Move, Posl!, MPlist),

satall (ftdvice, MPlist, RootPos, FTreesl. %

% - satall{ _, [], _, []). satall { Advice, [Hove..Pos! MPlist], RootPos, (Move..FT I MFTs]):-

sat(Advice, Pos, RootPos, FT),

satall(Advice, MPlist, RootPos, MFTs).

* : - % , AND/OR/KOT

holds! Goall and Goal2, Pos, RootPos):-!, holds[ Goall, Pos, RcotPos), holds (Goal2, Pos, RootPos!.

holds{ Goall or Goal2, Pos, RootPos):-!, (holds(Goall, Pos, RootPcs)

holds(Goal2, Pos, RootPo3)). holds[ not Goal, Pos, RootPos); -!,

not holds[ Goal, Pos, RootPos). holds(Pred, Pos, RootPos):-

(Cond =..[ Pred, Pos] \ RootPos

i

Cond =..[ Pred, Pos, RootPos]), call(Cond).

%

move! MCI and M.C2, Pos, Move, Posl):-!, novel MCI, Pos, Move, Posl), move 1 MC2, Pos, Move, Posl). move! MCI then MC2, Pos, Move, Posl):-!, (move! MCI, Pos, Move, Posl) i

move! MC2, Fos, Move, Posl)). %

better-goal [ BG: _, BG!. hoidinggoai(BG: HG: _, HG). usmoveconstrf BG: HG: UMC: _, UMC). theramoveconstrl BG: HG: UMC; , TMC). member! x, [X IL]). member! X, [Y I L] }:-member (X, L),


548


II. Prolog


, 22.4, , , - . - playgame(Pos)

Pos , . Pos , , . , , . , , end_of_game (, ).

,

Move..[ Replyl..Ftreel, Reply2,,Ftree2,...]

".." - , Move - , Replyl, Reply2 .. - , a Ftreel, Ftree2 .. - , .

22.6.2. " "

, , , , . .

, , , .

1. .

2. , , .

3. , .

4. 1, 2 3 , 2 3 (.. ).

5. 1, 2, 3 4, , , .

AL0 22.5. AL0 (. 22.4). . 22.4 , , .


22.



 

             
           
             
      w      
             
      : :    
             
             

squeeze


 

               
    V          
             
      <s?        
               
               
               
               

 


 



1'11,(1-: ■■! | -III IK


J


 


               
      V        
        a      
      <S>-        
               
               
               
               





:


: 2015-10-01; !; : 363 |


:

:

- , 20 40 . - .
==> ...

1473 - | 1439 -


© 2015-2024 lektsii.org - -

: 0.018 .