-3

I copied this code from the mesa introductory tutorial. the code is below

from tkinter import N
import mesa

class MoneyAgent(mesa.Agent):
    """An agent with fixed initial wealth."""

    def __init__(self, unique_id, model):
        super().__init__(unique_id, model)
        self.wealth = 1
    def step(self):
        # The agent's step will go here.
        #for demonstration purposeses we will print the agent's unique_id
        print("Hi, I am agent " + str(self.unique_id) + ".")
class MoneyModel(mesa.Model):
    """ A model with some number of agents."""
    def__init__(self, N):
        self.num_agents = N
        self.schedule = mesa.time.randomActivation(self)
        # Create agents
       
        for i in range(self.num_agents):
            a = MoneyAgent(i, self)
            self.schedule.add(a)

    def step(self):
        """Advance the model by one step."""
        self.schedule.step()

The code I am apparently missing syntax is

def__init__(self, N):

and

 self.schedule.step()

I don't quite understand why it says I am missing an expression, since I copied the code exactly as it was typed.

Parakeet
  • 1
  • 3

1 Answers1

2

To be written as:
def is a keyword and you connected def with function name __init__ which is a syntax error

def __init__(self, N):
Bibhav
  • 1,579
  • 1
  • 5
  • 18