create_model
Create and load a new NetLogo model from code. Optionally add interface widgets like sliders, switches, buttons, monitors, and plots.
Instructions
Create a new NetLogo model from code and load it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | NetLogo model code. Can be just the procedures (globals, breeds, setup, go, etc.) — the .nlogox envelope will be added automatically. Or provide a full .nlogox XML file. | |
| widgets | No | Optional interface widgets. Each item is an object: {"type": "slider", "variable": "num-sheep", "min": 0, "max": 250, "default": 100, "step": 1, "label"?, "units"?} {"type": "switch", "variable": "show-trails?", "default": false} {"type": "button", "code": "setup", "label"?, "forever"?: false} {"type": "monitor", "code": "count sheep", "label"?, "precision"?: 0} {"type": "plot", "label"?: "populations", "x_axis"?, "y_axis"?, "pens": [{"code": "plot count sheep", "label"?, "color"?: "green", "mode"?: 0, "interval"?: 1}]} Plot pens redraw on every tick (and on update-plots). Pen colors: palette names (black/gray/white/red/orange/brown/yellow/green/ lime/turquoise/cyan/sky/blue/violet/magenta/pink) or AWT ints. IMPORTANT: slider/switch widgets DEFINE their variable — do NOT also declare it in `globals [...]` or the model won't compile. Include setup/go buttons yourself when passing widgets. When omitted, Setup/Go buttons are auto-added for procedures that exist in the code. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |