正在加载图片...
Problem 2 performance varies sharply depending on its opponent. For example ce how a strategys Use play-loop to play games among the five defined strategies. Noti well against Eye-for-Eye or against another Patsy, but it loses badly to Nasty. Pay special attention to Eye-for-Eye. Notice how it never beats its opponent-but it never loses badly. Create a matrix in which you show the average score for tournaments pitting all possible pairings of the five different strategies: Nasty, Patsy, Eye-for-Eye Spastic, Egalitarian. Describe the behavior you observe for the different strategies Problem 3 Games involving Egalitarian tend to be slower than other games. Why is that so? Use order-of-growth notation to explain your answer Alyssa P. Hacker, upon seeing the code for Egalitarian, suggested the following iterative version of the procedure (define (Egalitarian my-history other-history (define (majority-loop cs ds hist) (cond ((empty-history hist)(if (> ds cs)d ((string=? (most-recent-play hist)"c) (majority-loop ( 1 cs)ds (rest-of-plays hist))) (else (majority-loop cs ( 1 ds)(rest-of-plays hist))))) (majority-loop 00 other-history) Compare this procedure with the original version. Do the orders of growth(in time)for the two procedures differ? Is the newer version faster? Problem 4 Write a new strategy eye-for-two-eyes The strategy should always cooperate unless the opponent defected on both of the previous two rounds ( Looked at another way: eye- for-two-eyes should cooperate if the opponent cooperated on either of the previous two rounds. Play eye-for-two-eyes against other strategies. Describe the behavior yo observe Problem 5 and return the appropriate Eye-for-Eye-like strategy. For example, (make-eye-for-A A Write a procedure make-eye-for-n-eyes. This procedure should take a number as inp eyes 2) should return a strategy equivalent to eye-for-ty Use this procedure to create a new strategy and test it against the other strategies. describe the observed behavioProblem 2 Use play-loop to play games among the five defined strategies. Notice how a strategy's performance varies sharply depending on its opponent. For example, Patsy does quite well against Eye-for-Eye or against another Patsy, but it loses badly to Nasty. Pay special attention to Eye-for-Eye. Notice how it never beats its opponent - but it never loses badly. Create a matrix in which you show the average score for tournaments pitting all possible pairings of the five different strategies: Nasty, Patsy, Eye-for-Eye, Spastic, Egalitarian. Describe the behavior you observe for the different strategies. Problem 3 Games involving Egalitarian tend to be slower than other games. Why is that so? Use order-of-growth notation to explain your answer. Alyssa P. Hacker, upon seeing the code for Egalitarian, suggested the following iterative version of the procedure: (define (Egalitarian my-history other-history) (define (majority-loop cs ds hist) (cond ((empty-history? hist) (if (> ds cs) “d” “c”)) ((string=? (most-recent-play hist) “c”) (majority-loop (+ 1 cs) ds (rest-of-plays hist))) (else (majority-loop cs (+ 1 ds) (rest-of-plays hist))))) (majority-loop 0 0 other-history)) Compare this procedure with the original version. Do the orders of growth (in time) for the two procedures differ? Is the newer version faster? Problem 4 Write a new strategy eye-for-two-eyes. The strategy should always cooperate unless the opponent defected on both of the previous two rounds. (Looked at another way: eye￾for-two-eyes should cooperate if the opponent cooperated on either of the previous two rounds.) Play eye-for-two-eyes against other strategies. Describe the behavior you observe. Problem 5 Write a procedure make-eye-for-n-eyes. This procedure should take a number as input and return the appropriate Eye-for-Eye-like strategy. For example, (make-eye-for-n￾eyes 2) should return a strategy equivalent to eye-for-two-eyes. Use this procedure to create a new strategy and test it against the other strategies. Describe the observed behavior
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有