.


:




:

































 

 

 

 






. 11.6. depthfirst (

Path, Node, Solution)

11,1,

11,1. ,

% solve[ Node, Solution);

% solution ( * ) Node

solve { Mode, Solution):-

depthfirst ([], Mode, Solution).

'Solution o " (Node | Path] %

depthfirst(Path, Node, [Node i Path]):-goal; Node).

depthfirstl Path, Node, Sol}:-

s; Node, Nodel),

not member(Nodel, Path), %
... depthfirst.(_.[Node |....Path],...Nodel, Sol).............................................................................................

, . 11.5. , . , . , . , . , , . , Y , , .

() : . : depthfirst2{ Node, Solution, Maxdepth)


11,



 

, Maxdepth. , . 11.2.

11.2.

% depthfirst2 [ Node, Solution, Maxdepth):

% Solution Node , % Maxdepth

dePthfirst2C Node, [Node], _):-goal (Node).

depthfirst2(Node, [Node. Sol], Maxdepth):-Maxdepth > 0, s(Node, Model],

Maxl is Maxdenth - 1, depthfirst2(Model, Sol, Maxl).

(. 11.2) , , . {.. ), . , . , , , . . , 11.2, : depthf irst2 , 1.

, ; pathf Model, Mode?, Path)

Path - Nodel Node2
. ,
. path :
path! Bode, Node, [Node]). %

path; FirstNcde, LastNode, [LastHode I Path]):-

path! FirstNode, OneButLMt, Path), % , yaJM,

*
CneSutLast, LastNode), %

not member; LastNode, Path). %

, , . 11.4, .

?- path(a, Last, Path).

Last =

Path - [];

Last - b

Path = [b,a],*

Last =

Path = [c,a];

Last = d

Path = [d,b,aj;



II, Prolog


path, , . : , , , , . :

depth first iterative deepening Node, solution):-path(Mode, GoalKodi, Solution), goal GoalNode].

, , , . , , - "" , . , , , . , , , . , , ( ), . ; . . , , .





:


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


:

:

.
==> ...

1474 - | 1405 -


© 2015-2024 lektsii.org - -

: 0.01 .