You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve boid flocker model and documentation (#101)
* Improve boid flocker model
* Update Readme.md
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update model.py
* Update server.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
An implementation of Craig Reynolds's Boids flocker model. Agents (simulated birds) try to fly towards the average position of their neighbors and in the same direction as them, while maintaining a minimum distance. This produces flocking behavior.
4
6
5
7
This model tests Mesa's continuous space feature, and uses numpy arrays to represent vectors. It also demonstrates how to create custom visualization components.
6
8
9
+
## Installation
10
+
11
+
To install the dependencies use pip and the requirements.txt in this directory. e.g.
12
+
13
+
```
14
+
$ pip install -r requirements.txt
15
+
```
16
+
7
17
## How to Run
8
18
9
-
Launch the model:
19
+
* To launch the visualization interactively, run ``mesa runserver`` in this directory. e.g.
20
+
21
+
```
22
+
$ mesa runserver
23
+
```
24
+
25
+
or
26
+
27
+
Directly run the file ``run.py`` in the terminal. e.g.
28
+
10
29
```
11
-
$ python Flocker_Server.py
30
+
$ python run.py
12
31
```
13
32
14
-
Then open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press Reset, then Run.
33
+
*Then open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press Reset, then Run.
15
34
16
35
## Files
17
36
18
-
*[flockers/model.py](flockers/model.py): Core model file; contains the BoidModel class.
19
-
*[flockers/boid.py](flockers/boid.py): The Boid agent class.
20
-
*[flockers/SimpleContinuousModule.py](flockers/SimpleContinuousModule.py): Defines ``SimpleCanvas``, the Python side of a custom visualization module for drawing agents with continuous positions.
21
-
*[flockers/simple_continuous_canvas.js](flockers/simple_continuous_canvas.js): JavaScript side of the ``SimpleCanvas`` visualization module; takes the output generated by the Python ``SimpleCanvas`` element and draws it in the browser window via HTML5 canvas.
22
-
*[flockers/server.py](flockers/server.py): Sets up the visualization; uses the SimpleCanvas element defined above
37
+
*[boid_flockers/model.py](boid_flockers/model.py): Core model file; contains the Boid Model and Boid Agent class.
38
+
*[boid_flockers/SimpleContinuousModule.py](boid_flockers/SimpleContinuousModule.py): Defines ``SimpleCanvas``, the Python side of a custom visualization module for drawing agents with continuous positions.
39
+
*[boid_flockers/simple_continuous_canvas.js](boid_flockers/simple_continuous_canvas.js): JavaScript side of the ``SimpleCanvas`` visualization module; takes the output generated by the Python ``SimpleCanvas`` element and draws it in the browser window via HTML5 canvas.
40
+
*[boid_flockers/server.py](boid_flockers/server.py): Sets up the visualization; uses the SimpleCanvas element defined above
23
41
*[run.py](run.py) Launches the visualization.
24
-
*[Flocker Test.ipynb](Flocker Test.ipynb): Tests the model in a Jupyter notebook.
42
+
*[Flocker_Test.ipynb](Flocker_Test.ipynb): Tests the model in a Jupyter notebook.
25
43
26
44
## Further Reading
27
45
28
-
=======
29
-
* Launch the visualization
30
-
```
31
-
$ mesa runserver
32
-
```
33
-
* Visit your browser: http://127.0.0.1:8521/
34
-
* In your browser hit *run*
46
+
The following link can be visited for more information on the boid flockers model:
0 commit comments