Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
Astar
:- dynamic(open/1). :- dynamic(path/3). astar(S):- solution(S), terminalstate, !. astar(S):- solution(S). astar(S):- repeat, gotonextstate, solution(S), (terminalstate,!);true. solution(Path):- end(E), open(Path), Path=[_-E-_|_]. gotonextstate:- open([F-Place-G|T]), +\((open([F2-_-_]|_]), F2<F)), retract(open([F-Place-G|T])), forall(nextnode(F-Place-G,Next), assert(open([Next,F-Place-G|T]))). terminalstate:- solution(S), retractall(open(_)), retract(end(_)). nextnode(_-Place-G, F2-Place2-G2):- %generate each F2,Place2,G2 (for the next nodes) based on Place,G (from the current node) %additional data gathered along the path can be put in G %assert the Path from every A to B as path(A,B,Path) findpathsbetweenallnodes:- node(A), node(B), A\=B, assert(open([0-A-0])), assert(end(B)), astar(Path), assert(path(A,B,Path)).
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
jproba inicio 9 nov
Salgado Sanchez Ivan_Examen1
SQL Acosta
Amish
jproba inicio 12 nov
Prolog_Test
Superquerys_Segura_Sanchez
Espinoza Espinosa FL Ing del conocimiento
Prolog-superquery3
Superquerys Segura Sanchez
Please log in to post a comment.