我找到了nim game prolog代码的框架,该框架在prolog书的艺术中给出。但是,当我在swi prolog编辑器中以书中给出的原始格式运行代码时,我会遇到很多错误。我不确定代码本身是不完整还是逻辑混乱。如果有人有解决方案,那将是很棒的。 感谢。
答案 0 :(得分:0)
如果将PDF代码粘贴到源文件中,唯一的问题应该是将后引用替换为单引号(整体约1分钟)。然后我让这个对话框工作:
1 ?- goal.
Enter number of matches in heaps [N1, N2, N3]: [5,7,9].
I take 7 matches from 3th heap.
You have heaps of matches: [5,7,2]
Choose heap number from 1 to 3: 2.
Choose number of matches to take from 1 to 7: 2.
So now the heaps are: [5,5,2]
I take 2 matches from 3th heap.
You have heaps of matches: [5,5,0]
Choose heap number from 1 to 3: 3.
Illegal move! Try again.
You have heaps of matches: [5,5,0]
Choose heap number from 1 to 3: 2.
Choose number of matches to take from 1 to 5: 2.
So now the heaps are: [5,3,0]
I take 2 matches from 1th heap.
You have heaps of matches: [3,3,0]
Choose heap number from 1 to 3: 1.
Choose number of matches to take from 1 to 3: 3.
So now the heaps are: [0,3,0]
I take 3 matches from 2th heap.
I won! :)
true
.