Skip to content

Commit

Permalink
best-practices: Update Model Layout section (#2424)
Browse files Browse the repository at this point in the history
Update the Model Layout section of the best-practices to the current way we structure our examples.
  • Loading branch information
EwoutH authored Oct 26, 2024
1 parent 9e45708 commit e1d4811
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions docs/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@ Here are some general principles that have proven helpful for developing models.
## Model Layout

A model should be contained in a folder named with lower-case letters and
underscores, such as `thunder_cats`. Within that directory:

- `README.md` describes the model, how to use it, and any other details.
Github will automatically show this file to anyone visiting the directory.
- `model.py` should contain the model class. If the file gets large, it may
make sense to move the complex bits into other files, but this is the first
place readers will look to figure out how the model works.
- `server.py` should contain the visualization support, including the server
class.
- `run.py` is a Python script that will run the model when invoked via
`mesa runserver`.

After the number of files grows beyond a half-dozen, try to use sub-folders to
organize them. For example, if the visualization uses image files, put those in
an `images` directory.

The [Schelling](https://github.com/projectmesa/mesa-examples/tree/main/examples/schelling) model is
a good example of a small well-packaged model.
underscores, such as `wolf_sheep`. Within that directory:

- `Readme.md` describes the model, how to use it, and any other details.
- `model.py` should contain the model class.
- `agents.py` should contain the agent class(es).
- `app.py` should contain the Solara-based visualization code (optional).

You can add more files as needed, for example:
- `run.py` could contain the code to run the model.
- `batch_run.py` could contain the code to run the model multiple times.
- `analysis.py` could contain any analysis code.

Input data can be stored in a `data` directory, output data in an `output`, processed results in a `results` directory, images in an `images` directory, etc.

All our [examples](examples) follow this layout.

## Randomization

Expand Down

0 comments on commit e1d4811

Please sign in to comment.