正在加载图片...
The values from the game matrix are stored in a list named *game-association-list This list is used to calculate the scores at the end of the iterated game (define *game-association-list* (list (list (list c"c)(list 33)) (list (list (list (list d""c) (list 50) (1ist(1ist"d""d")(1ist11)))) Thus, if both players cooperate, the payoff to each player is a 3, if one player cooperates and the other defects, the defecting player gets a payoff of 5, the cooperating player gets a zero payoff, if both players defect, each gets a payoff of 1 Some sample strategies are given in the code. Nasty and Patsy are particularly simple, each returns a constant value regardless of the histories spastic also ignores the histories and chooses randomly between cooperation and defection. You should study Egalitarian and Eye-for-Eye to see that their behavior is consistent with the descriptions in the previous section Problem 1 To be able to test out the system, we need to complete a definition for extract-entry This procedure will retrieve the payoff information from the game association list. The procedure's behavior is as follows: it takes as input a play, represented as a list of choices for each strategy (i.e,a"c"or a d), and the game association list. Thus a play will in this case be a list of two entries(since there are two players), each of which is the choice of action for that player. Each entry in the game association list is a list itself, with a first element representing a list of game choices, and the second element representing a list of scores(or payoffs)for each player. Thus extract-entry wants to search down th association list trying to match its first argument against the first element of each entry in the game association list, one by one. When it succeeds, it returns that whole entry For example, we expect the following behavior (define a-play (make-play c"d") (extract-entry a-play *game-association-list* alue:(("c〃"d")(05)) Write the procedure extract -entry, and test it out using the above case *game- ciation-list*. Turn in a copy of your documented procedure and some test examples. You may want to use a diagram of the list structure to guide the creation of your codeThe values from the game matrix are stored in a list named *game-association-list*. This list is used to calculate the scores at the end of the iterated game. (define *game-association-list* (list (list (list “c” “c”) (list 3 3)) (list (list “c” “d”) (list 0 5)) (list (list “d” “c”) (list 5 0)) (list (list “d” “d”) (list 1 1)))) Thus, if both players cooperate, the payoff to each player is a 3, if one player cooperates and the other defects, the defecting player gets a payoff of 5, the cooperating player gets a zero payoff, if both players defect, each gets a payoff of 1. Some sample strategies are given in the code. Nasty and Patsy are particularly simple; each returns a constant value regardless of the histories. Spastic also ignores the histories and chooses randomly between cooperation and defection. You should study Egalitarian and Eye-for-Eye to see that their behavior is consistent with the descriptions in the previous section. Problem 1 To be able to test out the system, we need to complete a definition for extract-entry. This procedure will retrieve the payoff information from the game association list. The procedure's behavior is as follows: it takes as input a play, represented as a list of choices for each strategy (i.e., a “c” or a “d”), and the game association list. Thus a play will in this case be a list of two entries (since there are two players), each of which is the choice of action for that player. Each entry in the game association list is a list itself, with a first element representing a list of game choices, and the second element representing a list of scores (or payoffs) for each player. Thus extract-entry wants to search down the game association list trying to match its first argument against the first element of each entry in the game association list, one by one. When it succeeds, it returns that whole entry. For example, we expect the following behavior: (define a-play (make-play “c” “d”)) (extract-entry a-play *game-association-list*) ;Value: ((“c” “d”) (0 5)) Write the procedure extract-entry, and test it out using the above case *game￾association-list*. Turn in a copy of your documented procedure and some test examples. You may want to use a diagram of the list structure to guide the creation of your code
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有