mesa
mesa copied to clipboard
frontend: Initialize Jupyter space widget via Bokeh
To test this:
pip install bokeh panel- Initialize a fresh empty .ipynb
- Copy the entirety of https://github.com/projectmesa/mesa/blob/main/examples/schelling/model.py into the first cell
- Put this into the 2nd cell
# #d62728 is tab:red, #1f77b4 is tab:blue
portray = lambda agent: "#d62728" if agent.type == 0 else "#1f77b4"
jv = mesa.visualization.JupyterSpaceVisualization(Schelling, portray)
jv.pane
- Put this into the 3rd cell:
jv.run() - In the navigation bar of the Jupyter web UI, click Cell > Run All
This is based on @dmnfarrell 's awesome blog post.
Closed in favor of discussion in https://github.com/projectmesa/mesa/discussions/1622.