As Prolog doesn't allow to switch out the search algorithm (why not? it's been over 40 years), you have to roll one yourself.Ītomic_list_concat("],S). You really need breadth-first search (or rather, Iterative Deepening). In the code below, the check is done by fail_if_visited/2.Īdditionally, a depth-first search according to the above will find a solution path, but the will likely not be a short path and not the solution sought. actually a nice exercise select a move/2 probabilistically. Otherwise the program may cycle forever (depending on how it hits the move/2 move-generating predicate. You have to check on each state expansion whether a new state might already be on the path. In fact, you construct the path through state path on return only in the third argument here: path(X,Y,). (Additionally, the solution you give is not a reachable state, the second line has a void on a wrong position, plus the path is reversed).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |