You will write the pseudocode for a simple game playing system, which plays against a user. Let’s call the program & the user UA (user agent). PA and UA are in a magical world, in which a dragon can appear.
PA and UA both know that they are being watched by a troll. PA and UA know that the troll will give them coins depending on their joint behavior when the dragon appears. If they both do nothing, the troll will think they are nice, animal lovers and will give them each 3 gold coins. If they both draw their swords on the dragon, the troll will think they are stressed out and over-reacting, and give them 1 coin each. However, if the PA draws its sword and the UA does nothing, the troll will think that the PA is very brave and that UA is a coward, and give PA 5 coins, and UA nothing. Similarly, if UA draws its sword and PA does nothing, then the UA will seem brave and get 5 coins, and PA will get nothing.
2007-03-21
15:30:11
·
1 answers
·
asked by
Facilitate
1
in
Computers & Internet
➔ Programming & Design
Here is a summary:
Reaction to Dragon amount of coins received both PA and UA do nothing PA gets 3, UA gets 3 both PA and UA draw their swords PA gets 1, UA gets 1
PA draws sword, UA does nothing PA gets 5, UA gets 0 PA does nothing, UA draws sword PA gets 0, UA gets 5
A game is defined by one appearance of the dragon, a decision by your program, and a decision by the user. Coins are given to each player according to the table above. Your program will control this game, play the part of the PA, and also keep track of the number of coins it collects over repeated games. Your program wants to maximize the number of coins it gets over repeated games. Your program will follow a particular strategy. For the first game, you can have it do whatever you want: nothing or draw its sword. But after that, your program will make its next decision depending on the joint outcome of the game just played. When both the user and program act peace loving (do nothing),both get 3 coins each.
2007-03-21
15:32:59 ·
update #1
Here is a summary:
Reaction to Dragon amount of coins received both PA and UA do nothing PA gets 3, UA gets 3 both PA and UA draw their swords PA gets 1, UA gets 1
PA draws sword, UA does nothing PA gets 5, UA gets 0 PA does nothing, UA draws sword PA gets 0, UA gets 5
A game is defined by one appearance of the dragon, a decision by your program, and a decision by the user. Coins are given to each player according to the table above. Your program will control this game, play the part of the PA, and also keep track of the number of coins it collects over repeated games. Your program wants to maximize the number of coins it gets over repeated games. Your program will follow a particular strategy. For the first game, you can have it do whatever you want: nothing or draw its sword. But after that, your program will make its next decision depending on the joint outcome of the game just played. When both the user and program act peace loving (do nothing),both get 3 coins each.
2007-03-21
15:33:36 ·
update #2
This is a good reward and so your program will decide to repeat its decision to do nothing in the next game. However, an even bigger reward occurs when your program decided to draw its sword (5 coins) and the user decided to act peace loving (did nothing and got 0 coins)). When this situation occurs, your program will repeat its decision to draw its sword on the very next game.
Your program will switch its decision in the other two cases with worse outcomes, from its viewpoint: when it did nothing but the user drew sword (PA gets 0 and UA gets 5), and when both PA and UA drew swords (1 coin each). These are not very good outcomes from the PA’s viewpoint, so it switches its decision on the next game.
Your pseudocode should produce behavior like this:
How many games do you want to play? 3 {user enters 3}
Game 1.
I’ve made my decision. What is your decision? : S {user enters S for sword}
My decision: sword. Your decision: sword I have 1 coins. You have 1 coins.
Game ends
2007-03-21
15:35:41 ·
update #3