Skip to main content
Version: 🚧 Alpha 🚧

The GAML Editor - Generalities

The GAML Editor provides syntax highlighting, validation feedback and controls for experiments defined in the open model. Validation can report errors in the editor and in the Validation view.

Creating a first model​

Editing a model requires that at least one project exists in the User category. If there is none, right-click on User and choose New... > Project... (if you already have user projects and want to create a model in one of them, skip the next step).

The User category's context menu shows New with the Project command and the other project and model creation options.

The "New GAMA Project" dialog is then displayed, offering you to enter the name of the project and, optionally, the group it should belong to in the User category. Two checkboxes let you ask for a first model file to be created right away (the default), and for the project to be configured as a test project, which places it in the Tests directory of the workspace and makes it appear in the Tests category rather than in User (see test models). An error is displayed if the project name already exists in the workspace, in which case you will have to change it. Two projects with similar names cannot coexist in the workspace (even if they belong to different categories).

The New GAMA Project dialog shows the project name, optional group, test-project option and create-model option.

If you want to create a new model file in your project, navigate to it, right-click on it and open the New... submenu. It offers, depending on the element you clicked on:

  • Model...: to create a normal .gaml model file used to define your model.
  • Test...: to create a unit test experiment. It is typically used to define some unit test on a given model, to ensure its quality and prevent regression bugs.
  • File... and Folder...: to add a plain resource (data file, image, include) or a folder to the project.
  • Project... and Group...: to create a new project, respectively a new group of projects, under the category you clicked on.

The same dialog writes an experiment as a separate file: it holds two tabs, Model and Standalone experiment, the second one producing a file that contains only an experiment on an existing model.

The New submenu for the User category lists project, group, model, test experiment, test file and folder commands.

Create a new model or test file​

A dialog titled New GAML file (page "New model") is displayed. On its Model tab it asks for: a Name (the name of the model, which may differ from the name of the file but cannot contain white spaces or punctuation), a Container (pre-filled with the project you clicked on, e.g. /Wiki_Captures/models, changeable through Browse...; an error is reported if it does not exist) and a File name (an error is reported if it already exists in that container). Two further fields let you give the main species of the model the Skills you select and a Control architecture (the default being reflex). Three collapsible sections complete the page: Advanced, Attributes and Documentation. The Attributes section lists the attributes of the species (the built-in ones of agent and model are offered for redefinition, with their type and origin) and lets you Add or Remove entries and describe the selected one (Name, Type, Initial value, Update, and a Redefine box). The file is written when you press Finish.

The New model wizard shows its Model tab with the model name, container, file name, skills, control architecture and collapsible sections.

Create a new experiment file​

A new New GAML file dialog is displayed. On the Standalone experiment tab:

  1. The Container defaults to the selected project or folder. Use Browse... to choose another existing workspace folder.
  2. Enter a unique File name ending in .gaml. The Experiment name defaults to the filename without punctuation; it must be a valid GAML name.
  3. Enter an Author. This field is required.
  4. Optionally choose a model to import with Browse.... The field displays the selected model's workspace path. Choose GUI or Headless for the experiment type.

The Standalone experiment tab shows its container, file and experiment names, required author, selected model and GUI or Headless type.

Status of models in editors​

Once this dialog is filled and accepted, GAMA will display the new "empty" model.

The wizard creates the model with an empty global block and a GUI experiment. The GAML editor validates the open model and updates its experiment controls from the validation result. The status area can report No experiments defined, Error(s) detected or Error(s) in imported files. When the model has experiments and no errors, the toolbar provides controls to launch them. See Validation of models.

The GAML editor shows an empty model and its GUI experiment launch control.

If the model source contains errors, the editor marks the affected code and displays the parser message at its source. The example below shows an unclosed experiment block.

The editor marks the missing closing brace and displays the parser message beside the affected line.

Validation markers are also collected in the Validation view. Select a marker to navigate to its location; hover over an editor marker to read its message.

When validation finds no errors and the model defines an experiment, the editor provides a control for launching it. See Running experiments for details.

The experiment controls update when the model changes. Depending on the editor preference Use a menu for experiments, experiments appear as individual controls or in a menu.

The GAML editor shows the Ant Foraging model with its five experiment buttons above the source.

The toolbar on the top of the GAML editor displays, in addition to the green experiment buttons, a button to add an experiment in the current model.

Button to create a new experiment.

Editor Preferences​

Editor preferences include settings such as line numbers, fonts and syntax colors. Open Preferences... from the editor's context menu to change them.

The editor context menu also opens Preferences... for editor-wide settings.

The GAML editor context menu includes Preferences... along with editing and navigation commands.

These preferences apply across GAMA workspaces for the current operating-system account. The Editor options menu also contains controls for the active editor; see GAML Editor tools.

The Editors preferences page shows editor options, font controls and syntax-colour settings.

Additional information in the Editor​

You can choose to display or not some information in your Editor, from the Editor options menu (the three dots at the right of the toolbar of the GAML editor), available when the GAML editor is active.

The Presentation submenu contains controls for zoom, editor layout, line numbers, code folding, word wrap, the markers overview and inline markers. It also contains Use a menu for experiments. The menu's view commands open or close the Outline, Navigation, versions and dependencies views when available.

The GAML editor's Presentation submenu is open beside the Editor options menu and toolbar.

Multiple editors​

The editor can be split or cloned from Editor options > Presentation to show more than one editor area at a time.

The editor is split into two side-by-side areas, each showing the same GAML model.

Local history​

The editor provides access to saved versions of a model through Show versions in Editor options. This history is separate from a version-control system such as Git.

The GAML editor's Editor options menu is open, with Show versions outlined in red.

The red outline marks the command that opens the versions view for the active model.

The versions view lists saved versions. Select a version to compare it with the current file.

The Versions view shows a saved version selected and the Compare with current command.

The comparison identifies changes between the selected version and the current file.

The comparison shows the current GAML file beside a saved local version, with the changed line highlighted.

This short introduction to GAML editors is now over. You might want to take a look, now, at how the models you edit are parsed, validated and compiled, and how this information is accessible to the modeler.