0

I am following the tutorial of the python mesa ( http://mesa.readthedocs.io/en/latest/index.html ) and i can't get the visualization from the advanced tutorial ( http://mesa.readthedocs.io/en/latest/tutorials/adv_tutorial.html ) up and running.

Code where I am running into trouble:

server = ModularServer(SwarmportModel, 
                   [grid], 
                   "SwarmportModel", 
                   100, 10, 10)

Error i get:

server = ModularServer(SwarmportModel, [grid], "SwarmportModel", 100, 10, 10)

TypeError: __init__() takes from 3 to 5 positional arguments but 7 were given

When i ommit the 3 arguments in last line of the code i mentioned, i get the error message that 3 arguments are missing.

server = ModularServer(SwarmportModel, [grid], "SwarmportModel",)
TypeError: __init__() missing 3 required positional arguments: 'N', 'width', and 'height'

Has anyone got any idea what I am doing wrong?

Spaceghost
  • 6,835
  • 3
  • 28
  • 42
  • It may be that the last three arguments can be placed in a tuple or list. I am not familiar with `mesa`, but the error you're getting is complaining about too many arguments being supplied. Try `server = ModularServer(SwarmportModel, [grid], "SwarmportModel", (100, 10, 10))` for starters. – Ron Norris Jul 13 '17 at 13:41
  • Thx for the tip, already tried some other thinks, also making a tuple. FYI the error with tuple is: AttributeError: 'tuple' object has no attribute 'items' – user8302148 Jul 13 '17 at 14:04
  • 1
    Solved the problem by making a dictionary: dict = {'N':100,'width':10,'height':10} – user8302148 Jul 13 '17 at 14:10

1 Answers1

0

I appear to have had the same issue and they said I ran an outdated version, which I didn't verify: https://github.com/projectmesa/mesa/issues/397

server = ModularServer(SwarmportModel, [grid], "SwarmportModel", {"N": 100, "width": 10, "height": 10})

In any case the dict workaround works.