original_docstring: 
          Decide what good to trade in and how much.
          Look for the most in demand good, or the most expensive good at the home Province
          Find a province near home province where its the cheapest and there's inventory
          
docstring: Decide what good to trade in and how much.
  Look for the most in demand good, or the most expensive good at the home Province
  Find a province near home province where its the cheapest and there's inventory
docstring_tokens: Decide what good to trade in and how much . Look for the most in demand good or the most expensive good at the home Province Find a province near home province where its the cheapest and there ' s inventory
code: def decide_trade_plan(self):
          """
          Decide what good to trade in and how much.
          Look for the most in demand good, or the most expensive good at the home Province
          Find a province near home province where its the cheapest and there's inventory
          """
          self.trade_amount = 5
          most_demanded_goods = self.home.market.goods_demand_ratio(day_range=1)
          most_demanded_goods = sorted(most_demanded_goods.items(), key=lambda i: i[1], reverse=True)
  
          # if we already had a trade good, refresh ideal inventory
          if self.trade_good:
              self.update_ideal_inventory()
  
          if DEBUG: print("Finding a Good to trade:")
  
          for good, demand in most_demanded_goods:
              if demand > 0:
                  # find nearby provinces where this has inventory and the price is lower
                  price_at_home = self.home.market.mean_price(good)
                  if DEBUG: print("Good: {}, Demand: {}, Price: ${}".format(good.title, demand, price_at_home))
                  neighboring_markets = [p.market for p in self.location.owned_neighbors]
                  neighboring_markets = [m for m in neighboring_markets if m.supply_for(good) > self.trade_amount]
                  neighboring_markets.sort(key=lambda m: m.supply_for(good), reverse=True)
  
                  if len(neighboring_markets) > 0:
                      # we found places where this good is cheaper and in inventory
                      target = neighboring_markets[0].location
                      price_at_target = target.market.mean_price(good)
  
                      # only trade with prices where we can make money
                      if price_at_home > price_at_target:
                          offset = 0
                          if good is Good.bread:
                              offset = 1
                          self.inventory.set_ideal(good, self.trade_amount + offset)
                          self.trade_location = target
                          if DEBUG:
                              print("\tTarget: {}, Supply: {}, Price: ${}, Price at home: ${}".format(
                                  self.trade_location.name,
                                  self.trade_location.market.supply_for(good),
                                  self.trade_location.market.mean_price(good),
                                  price_at_home)
                              )
                          self.trade_good = good
                          return
                      else:
                          if DEBUG: print("\tPrice is higher at target (home: ${} target: ${})".format(price_at_home, price_at_target))
                  else:
                      if DEBUG: print("\tNo markets selling {} found".format(good))
code_tokens: def decide_trade_plan ( self ) : self . trade_amount = 5 most_demanded_goods = self . home . market . goods_demand_ratio ( day_range = 1 ) most_demanded_goods = sorted ( most_demanded_goods . items ( ) , key = lambda i : i [ 1 ] , reverse = True ) if self . trade_good : self . update_ideal_inventory ( ) if DEBUG : print ( "Finding a Good to trade:" ) for good , demand in most_demanded_goods : if demand > 0 : price_at_home = self . home . market . mean_price ( good ) if DEBUG : print ( "Good: {}, Demand: {}, Price: ${}" . format ( good . title , demand , price_at_home ) ) neighboring_markets = [ p . market for p in self . location . owned_neighbors ] neighboring_markets = [ m for m in neighboring_markets if m . supply_for ( good ) > self . trade_amount ] neighboring_markets . sort ( key = lambda m : m . supply_for ( good ) , reverse = True ) if len ( neighboring_markets ) > 0 : target = neighboring_markets [ 0 ] . location price_at_target = target . market . mean_price ( good ) if price_at_home > price_at_target : offset = 0 if good is Good . bread : offset = 1 self . inventory . set_ideal ( good , self . trade_amount + offset ) self . trade_location = target if DEBUG : print ( "\tTarget: {}, Supply: {}, Price: ${}, Price at home: ${}" . format ( self . trade_location . name , self . trade_location . market . supply_for ( good ) , self . trade_location . market . mean_price ( good ) , price_at_home ) ) self . trade_good = good return else : if DEBUG : print ( "\tPrice is higher at target (home: ${} target: ${})" . format ( price_at_home , price_at_target ) ) else : if DEBUG : print ( "\tNo markets selling {} found" . format ( good ) )
short_docstring: Decide what good to trade in and how much.
short_docstring_tokens: Decide what good to trade in and how much .
comment: """
          Decide what good to trade in and how much.
          Look for the most in demand good, or the most expensive good at the home Province
          Find a province near home province where its the cheapest and there's inventory
          """$SEP$# if we already had a trade good, refresh ideal inventory$SEP$# find nearby provinces where this has inventory and the price is lower$SEP$# we found places where this good is cheaper and in inventory$SEP$# only trade with prices where we can make money