maze.plg

来自「this is a prolog implementation to solve」· PLG 代码 · 共 18 行

PLG
18
字号
% allow the addition of new paths as they are found.:-dynamic(path/1).% data describe movements in mazemove(a,b). move(b,c). move(c,d).  move(c,e). move(e,f).% The simplest path is a single movementpath([X,Y]):-move(X,Y).% construct more complex paths from simpler paths and movementsgo([X,Y|Z]):-path([Y|Z]), move(X,Y),assert_if_new(path([X,Y|Z])), listing(path).go:-go(Path), fail.% add Fact to database if it is not already a Clause in the databaseassert_if_new(Fact):-clause(Fact,true),!; assert(Fact).

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?