-
Notifications
You must be signed in to change notification settings - Fork 20
ClassDefinition
RoiArthurB edited this page Jul 29, 2026
·
3 revisions
GAML 2026 introduces the class and object keywords, bringing full object-oriented programming support beyond species. Classes allow you to define pure data/logic types that are not agents — they have no reflex, no schedule, and no population. They are simply structured values with attributes and methods.
- A class is a blueprint for creating objects (instances). Declared with
class ClassName { ... }. - An object is a value created by calling the class constructor:
ClassName(attr: value, ...). - Classes can have attributes (like species variables) and actions (like species actions, but on objects).
- Classes support inheritance with
parent: ClassName. - Classes can be virtual (abstract) with
virtual: true— they cannot be instantiated directly. - Objects can be stored in any GAML variable, passed as arguments, stored in lists, and used as map keys.
-
Class Definition and Instantiation — Declare a class, create objects with the constructor syntax
ClassName(attr: value), store objects in variables and lists. -
Attributes and Actions — Read and write attributes (dot notation:
obj.attr <- value), call actions (obj.action()), chained calls, comparing objects, passing objects as arguments. -
Inheritance — Extend a class with
parent:, override actions, call parent implementation withsuper.action(), multi-level inheritance, runtime type testing withis. - Virtual Classes — Declare virtual (abstract) classes and virtual (abstract) actions, polymorphism, partial abstract classes, concrete implementations.
- Advanced Features — Objects as agent attributes, passing objects between agents, objects in species, objects as map keys, object equality.
| Feature | Class | Species |
|---|---|---|
| Is an agent? | No | Yes |
| Has reflex/actions/behaviors? | No (methods are plain actions) | Yes |
| Has a population? | No (no count or lifecycle) | Yes (count, init, lifecycle) |
| Can be an agent attribute? | Yes | No (species attributes are values) |
| Used for? | Pure data types, structures, utilities | Simulated entities in the world |
- Installation and Launching
- Workspace, Projects and Models
- Editing Models
- Running Experiments
- Running Headless
- Preferences
- Troubleshooting
- Introduction
- Manipulate basic Species
- Global Species
- Defining Advanced Species
- Defining GUI Experiment
- Classes and Objects
- Exploring Models
- Optimizing Models
- Multi-Paradigm Modeling
- Manipulate OSM Data
- Cleaning OSM Data
- Diffusion
- Using Database
- Using Dataframes
- Using FIPA ACL
- Using BDI with BEN
- Using Driving Skill
- Manipulate dates
- Manipulate lights
- Using comodel
- Save and restore Simulations
- Using network
- Writing Unit Tests
- Ensure model's reproducibility
- Going further with extensions
- Built-in Species
- Built-in Skills
- Built-in Architecture
- Statements
- Data Type
- File Type
- Stats Extension
- Sound Extension
- BDI Extension
- FIPA Skill
- Expressions
- Exhaustive list of GAMA Keywords
- Installing the development version
- Developing Extensions
- Introduction to GAMA Java API
- Using GAMA flags
- Creating a release of GAMA
- Documentation generation
- Predator Prey
- Road Traffic
- Incremental Model
- Luneray's flu
- BDI Agents
- Forager RL
- SIR Analysis
- 3D Model