title: How to use scipy's minimize within a class?
body: <p>I'm new to python so this might be a stupid question, however I couldn't find an answer to this anywhere.</p>
  <p>I'm trying to find the optimal reaction for a player given the action of another player. The situation is your typical Bertrand price competition for those familiar economics. The code is as follows:</p>
  <pre><code>import numpy as np
  from scipy.optimize import minimize
  
  class Player:
      def __init__(self):
          self.action = np.random.choice(np.linspace(0, 1, 11))
  
      def payoff(self, other):
          if self.action &lt; other.action:
              return (1 - self.action) * self.action
          elif self.action == other.action:
              return 0.5 * (1 - self.action) * self.action
          else:
              return 0
  
      def best_reply(self, other):
          br = minimize(-self.payoff, 0.5, other)
          return br['x']
  
  A = Player()
  B = Player()
  
  print(A.best_reply(B))
  </code></pre>
  <p>When I run the above code I get an error of:</p>
  <pre><code>TypeError: bad operand type for unary -: 'method'
  </code></pre>
  <p>Can someone explain to me why this is? I was able to circumvent the problem by multiplying the payoffs by -1 and removing the '-' from the best_reply function. However, when I then run the code I get:</p>
  <pre><code>TypeError: payoff() takes 2 positional arguments but 3 were given
  </code></pre>
  <p>How come? The only arguments I've given are self (A) and the other player (B). If someone would be able to help me out by explaining what exactly I'm doing wrong and what the correct way of running such code is, I would be extremely grateful. Thank you in advance!</p>
  <p>Edit: Added imports to the code</p>