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,and G2 (the next node) based on Place,G (the current node). %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.
programa 2
superqueries_Steve
Test1
ejercicios de la coma
Astar
Fii
1M horses with recursion
jproba inicio 9 novV3
C4
o;uiop
Please log in to post a comment.