Inheriting Behaviors


This page describes an upcoming feature in HASH that has not yet been released.

One great feature offered by object-oriented programming languages is the ability to define a class of agents, and derive classes from classes (a process known as inheritance). This makes scaling out agents easy, but can also be constraining in terms of the ability to compose agents who may not fit neatly into pre-defined hierarchies.

The Object-Oriented Dilemma

Consider Arnold Schwarzenegger, the indomitable bodybuilder-actor-poltician. Is he a bodybuilder, an actor, or a politician?

The real world doesn't fit into neat hierarchies. Modeling agents who are of multiple classes, such as Arnie, isn't easy. Should you create actor a subclass of politician for the Governator and similarly-shaped peers such as actor-turned US President Ronald Reagan? Or would you be better off defining a sub-class of actors who are politicians? Why not start with bodybuilder as the top-level class? There's no easy answer, and when you're scaling a simulation to millions of agents things quickly become a mess.

Agent Types

In HASH, agents are in practice defined by their behaviors. While users are free to add a type field to their agents, and many simulation authors do so, these types have until now been symbolic labels that have made tracking agents over the course of simulations easier, and have primarily been used to generate descriptive metrics and plots.

We're now planning to introduce support for Agent Types in a forthcoming update, which go further. In the future, HASH Engine (hEngine) will attempt to match the type field of an agent to an entity type in HASH, where it contains the URL of an entity type schema.

Entity types created in HASH describe 'things'. In a simulation context these could for example be:

  1. agents (Agent Types); or
  2. actions taken by agents (Behaviors).

Entity types consist of properties, each of which has their own property types, and in some cases these may have default values. Entity types in HASH may contain a hash_simulation_behavior property containing one or more behaviors.

When an agent in a HASH simulation has its type declared going forward, if hEngine is able to match that type to a valid entity type URL, any behaviors specified in that schema's hash_simulation_behavior array will be attached to the agent.

There is no limit to the number of types that may be attached to an agent, and types may continue to be used descriptively without being linked to entity type URIs.

As part of these changes, you'll be able to attach any number of HASH simulation behavior files to an entity type under the protected hash_simulation_behavior property.

Previous

Join our community of HASH developers