i am required to do this :
You will write the C++ program for a simple game playing system, which plays against a user. Let’s call the program P and the user U. P and U are in a magical world, in which a dragon can appear.
P and U both know that they are being watched by a troll. P and U 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 10 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 5 coin each. However, if the P draws its sword and the U does nothing, the troll will think that the P is very brave and that U is a coward, and give P 20 coins, and U nothing. Similarly, if U draws its sword and P does nothing, then the U will seem brave and get 20 coins, and P will get nothing.
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 (your program and the user) according to the table above. Your program will control this game, play the part of the P, 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 10 coins each. 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 (20 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 (P gets 0 and U gets 20), and when both P and U drew swords (5 coin each). These are not very good outcomes from the P’s viewpoint, so it switches its decision on the next game.
Your program 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 5 coins. You have 5 coins.
Game 2.
I’ve made my decision. What is your decision? : N {user enters N for nothing}
My decision: nothing. Your decision: nothing
I have 15 coins. You have 15 coins. {updates the total coins}
Game 3
I made my decision. What is your decision? : S
My decision: nothing. Your decision: sword
I have 15 coins. You have 35 coins.
End of games.
Obviously, to be fair, your program must set its decision before asking the user what his or her decision is.
I have worked on this programming for a while ,
but always have problems here and there ,~
so if anyone can help me with it ?
Thanks a lot ~