正在加载图片...
Problem 9 Revise the Scheme code for the two-player game to make a three-player iterated game The program should take three strategies as input, keep track of three histories, and print out results for three players. You need to change only three procedures: play-loop, print-out-results and get-scores(although you may also have to change your definition of extract -entry if you did not write it in a general enough manner). We would suggest that you make copies of the necessary code and rename them so that you can separate the two person version from the three person one You also need to change *game-association-list* as follows: (define *game-association-list* (list (list (list c"cc)(list 444)) (list (list cc"d"(list 2 25) (list (list c""d"c")(l t252)) (list (list d"cc)(list 5 22) (1ist(1ist"c""d""d")(1ist033)) (list (list d"d"c)(list 33 0)) (list (list d""d")(1ist111)))) Problem 10 Write strategies Patsy-3, Nasty-3, and spastic-3 that will work in a three-player game. Try them out to make sure your code is working Write two new strategies: tough-Eye-for-Eye and soft-Eye-for-Eye Tough-Eye for-Eye should defect if either of the opponents defected on the previous round. Soft- Eye-for-Eye should defect only if both opponents defected on the previous round. Play some games using these two new strategies. Describe the observed behavior of the strategies Problem ll Write a procedure make-combined-strategies which takes as input two two-player strategies and a combining procedure. Make-combined-strategies should return a three-player strategy that plays one of the two-player strategies against one of the opponents, and the other two-player strategy against the other opponent, then calls the combining" procedure on the two two-player results. Here's an example: this call to make-combined-strategies returns a strategy equivalent to tough-Eye-for-Eye in Problem 10 (make-combined-strategies Eye-for-Eye Eye-for-Eye (lambda (r1 r2)(if (or (string=? r1 "d")(string=? r2 d"))d"c"))Problem 9 Revise the Scheme code for the two-player game to make a three-player iterated game. The program should take three strategies as input, keep track of three histories, and print out results for three players. You need to change only three procedures: play-loop, print-out-results and get-scores (although you may also have to change your definition of extract-entry if you did not write it in a general enough manner). We would suggest that you make copies of the necessary code and rename them so that you can separate the two person version from the three person one. You also need to change *game-association-list* as follows: (define *game-association-list* (list (list (list “c” “c” “c”) (list 4 4 4)) (list (list “c” “c” “d”) (list 2 2 5)) (list (list “c” “d” “c”) (list 2 5 2)) (list (list “d” “c” “c”) (list 5 2 2)) (list (list “c” “d” “d”) (list 0 3 3)) (list (list “d” “c” “d”) (list 3 0 3)) (list (list “d” “d” “c”) (list 3 3 0)) (list (list “d” “d” “d”) (list 1 1 1)))) Problem 10 Write strategies Patsy-3, Nasty-3, and spastic-3 that will work in a three-player game. Try them out to make sure your code is working. Write two new strategies: tough-Eye-for-Eye and soft-Eye-for-Eye. Tough-Eye￾for-Eye should defect if either of the opponents defected on the previous round. Soft￾Eye-for-Eye should defect only if both opponents defected on the previous round. Play some games using these two new strategies. Describe the observed behavior of the strategies. Problem 11 Write a procedure make-combined-strategies which takes as input two two-player strategies and a “combining” procedure. Make-combined-strategies should return a three-player strategy that plays one of the two-player strategies against one of the opponents, and the other two-player strategy against the other opponent, then calls the “combining” procedure on the two two-player results. Here's an example: this call to make-combined-strategies returns a strategy equivalent to tough-Eye-for-Eye in Problem 10. (make-combined-strategies Eye-for-Eye Eye-for-Eye (lambda (r1 r2) (if (or (string=? r1 “d”) (string=? r2 “d”))“d” “c”)))
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有