prices [ max_price_addon maximum of random value added to get price def __init__(self)"""paper buying agent""self time= self stock= self stock_history [memory of the stock history self price_history [memory of the price history def initial_percepts(self)"""return initial percepts""self stock_history append(self stockprice self prices[ ]+random randrange(self max_price_addonself price_history append(pricereturn {'price'price'instock'self stock def do(selfaction)"""does action (buyand returns percepts (price and instock)""used pick_from_dist({ : : : : : : }bought action['buy'self stock self stock+bought-used self stock_history append(self stockself time + price (self prices[self time%len(self prices)repeating pattern +random randrange(self max_price_addonplus randomness +self time// plus inflation self price_history append(pricereturn {'price'price'instock'self stockthe pick from dist method takes in item probability dictionaryand returns one of the items in proportion to its probability agents py -(continued def pick_from_dist(item_prob_dist)""returns value from distribution item_prob_dist is an item:probability dictionarywhere the probabilities sum to returns an item chosen in proportion to its probability ""ranreal random random(for (it,probin item_prob_dist items()if ranreal probversion june