Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 6. [bonus] Consider the following game. Each player can donate any integer amount of dollars, up to 10, in which case the other



image text in transcribedimage text in transcribed

Problem 6. [bonus] Consider the following game. Each player can donate any integer amount of dollars, up to 10, in which case the other receives double their donation, or can keep their money (as in class). If the donations are i, j, then Aij = 2j i and Bij 2i - j. = Write a python program to play this repeatedly against other similar programs. The decision at each step can depend on what you did in the past, and the other program did in the previous rounds. The program should be a function play (X, Y), where X,Y are lists of integers of our and their previous actions. (In the first round, these are empty lists.) The function should return a number in [0, 10], which is the amount that you decide to donate. You are allowed to use randomness. Each pair of programs will play each other 1000 times, accumulating their scores. All valid submissions get points, Top places get bonuses. Samples: #always donate def play (us, them): return 10 #donate random amount: def play (us, them): return random.randrange (11) #do what the opponent did last time. donate in round 1. def play (us, them): if len(them) == 0: return 10 return them [-1] # donate the average of the opponent donations: def play (us, them): if len(them) == 0: return 7 return int (round (sum (them)/len (them)))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To create a Python function for this game that adapts based on previous rounds we can try several strategies each of which can incorporate logic based ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete and Combinatorial Mathematics An Applied Introduction

Authors: Ralph P. Grimaldi

5th edition

201726343, 978-0201726343

More Books

Students also viewed these Mathematics questions