Beginners Interactive NetLogo Dictionary (BIND)
Farsi / Persian
NetLogo Models Library:
Note: If you download the NetLogo application, every model in the Models Library is included.
This model is based on the original Flocking model that has birds follow exactly the same set of rules, from which flocks emerge. It demonstrates using a Python package,
scikit-learn, within a NetLogo model through the
py extension in order to cluster the birds into groups, who are given matching colors in the view.
py:setup py:python is used to start the Python session and
py:run is used to let Python
scikit-learn packages for use during the model run. If you do not have these packages installed, the
py extension will show an error. Please install these packages in your Python environment before running the model.
The modifications for clustering are in the
go procedure, where
py:set is used to pass turtle data to Python as the
coords variable and the
vision NetLogo variable as the
py:runresult is called to use the
dbscan() Python function on the NetLogo data and the resulting cluster data is sent back to NetLogo and stored in the
clusters data is used to color the turtles into their groups.
See the original Flocking model for details on how the flocking-specific code works.
There is a bundle of other Python extension demo models,
py-demo-models.zip, available on the Python extension site.