我试图通过使用方案来实现一个博弈论算法。我写了一个代码片,命名为两个tat的tit。下面是代码:如何在计划中使用“cond”?
(define (tit-for-two-tat my-history other-history)
(cond ((empty-history? my-history) 'c)
((= 'c (most-recent-play other-history)) 'c)
((= 'c (second-most-recent-play other-history)) 'c)
(else 'd)))
我也试着写这样的:
(define (tit-for-two-tat my-history other-history)
(cond ((empty-history? my-history) 'c)
((= 'c (or (most-recent-play other-history) (second-most-recent-play other-history))) 'c)
(else 'd)))
游戏的情况是“囚徒困境”。 c表示坐标d表示缺陷。当我尝试运行此代码它给两个类型代码以下错误:
expects type <number> as 1st argument, given: 'c; other arguments were: 'c
我通过给这个函数作为参数传递给函数“发挥环”运行它。游戏循环给了我。
可能是什么问题?谢谢你的帮助。
是真的谢谢:) – user2870 2013-04-27 15:18:55