Skip to content

Commit 42880ac

Browse files
authored
Update migration_guide.md (#2347)
* Update migration_guide.md * Update migration_guide.md
1 parent 3054bac commit 42880ac

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/migration_guide.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ The `mesa.flat` namespace is removed. Use the full namespace for your imports.
4242

4343

4444
### Mandatory Model initialization with `super().__init__()`
45-
In Mesa 3.0, it is now mandatory to call `super().__init__()` when initializing your model class. This ensures that all necessary Mesa model variables are correctly set up and agents are properly added to the model.
45+
In Mesa 3.0, it is now mandatory to call `super().__init__()` when initializing your model class. This ensures that all necessary Mesa model variables are correctly set up and agents are properly added to the model. If you want to control the seed of the random number generator, you have to pass this as a keyword argument to super as shown below.
4646

4747
Make sure all your model classes explicitly call `super().__init__()` in their `__init__` method:
4848

4949
```python
5050
class MyModel(mesa.Model):
51-
def __init__(self, *args, **kwargs):
52-
super().__init__() # This is now required!
51+
def __init__(self, some_arg_I_need, seed=None, some_kwarg_I_need=True):
52+
super().__init__(seed=seed) # Calling super is now required, passing seed is highly recommended
5353
# Your model initialization code here
54+
# this code uses some_arg_I_need and my_init_kwarg
5455
```
5556

5657
This change ensures that all Mesa models are properly initialized, which is crucial for:

0 commit comments

Comments
 (0)