diff --git a/main.py b/main.py index f95e1bc..a4fafa3 100644 --- a/main.py +++ b/main.py @@ -148,6 +148,7 @@ class Market: self.trend_factor = self.generate_market_trend() self.update_economic_indicators() self.handle_market_events() + def calculate_price_change(self, product): demand_factor = self.total_bought[product] - self.total_sold[product] # Here you can define how strongly demand affects the price, e.g., 0.05 as in your original code @@ -463,13 +464,13 @@ class Company: total_value = stock_price * amount if action == 'buy': - return self._buy_stock(company_id, amount, total_value, is_ai) + return self._buy_stock(company_id, amount) elif action == 'sell': return self._sell_stock(company_id, amount, total_value, is_ai) else: return "Invalid stock action." - def _buy_stock(self, company_id, amount, total_value, is_ai): + def _buy_stock(self, company_id, amount): # Calculate the total number of shares currently owned total_shares_owned = sum(self._market.companies[company_id].own_stock_ownership.values()) available_shares = self.total_shares - total_shares_owned @@ -487,7 +488,6 @@ class Company: self._market.update_stock_ledger(company_id, self.player_id, amount) if company_id != self.player_id: - # Update buyer's stock_holdings for investments in other companies self.stock_holdings[company_id] += amount else: # Update own_stock_ownership when buying own shares