我試圖通過使用方案來實現一個博弈論算法。我寫了一個代碼片,命名爲兩個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