Prolog - 重新加载源文件
Prolog - reload source files
我刚刚使用 Sicstus 在 Prolog 中创建了一个游戏。
在游戏中我使用 assert
和 retract
来更新我使用的一些变量的值。
当游戏结束后,如果我不reconsult
源文件,重新运行游戏,那些变量与过去游戏的内容相同,这是有道理的。
所以我想问的是,是否存在某种内置谓词,我可以在游戏结束时调用它,以便它重新查询源文件,建立游戏的原始数据。 (我知道这是一种懒惰的方式。)
Perhaps you can remove the default facts from the file and write an initializer predicate that asserts them instead. Then you could retract all of them on a restart and rerun your initializer to set the defaults
– 潜伏者
这就是答案。
谢谢潜伏者。
我刚刚使用 Sicstus 在 Prolog 中创建了一个游戏。
在游戏中我使用 assert
和 retract
来更新我使用的一些变量的值。
当游戏结束后,如果我不reconsult
源文件,重新运行游戏,那些变量与过去游戏的内容相同,这是有道理的。
所以我想问的是,是否存在某种内置谓词,我可以在游戏结束时调用它,以便它重新查询源文件,建立游戏的原始数据。 (我知道这是一种懒惰的方式。)
Perhaps you can remove the default facts from the file and write an initializer predicate that asserts them instead. Then you could retract all of them on a restart and rerun your initializer to set the defaults
– 潜伏者
这就是答案。 谢谢潜伏者。