By default, Helipad creates agents with equiproportional breeds, cycling through the list of registered breeds as it creates agents of a specific primitive.
decideBreed allows the user to specify a function to determine which breed agents should be assigned when initialized. The hook runs only during the creation of parentless agents, i.e. when agents are initialized at the beginning of the model and when agents are created via the population control panel slider. It does not run when agents reproduce, as the breed is inherited from the primary parent by default.
The decideBreed hook will run every time a parentless agent of any primitive is created. There are corresponding primitive-specific hooks
[primitive]DecideBreed for a more narrow focus, e.g.
bankDecideBreed will only run for a
bank primitive. See
id — int
The globally unique ID assigned to the agent. See
breeds — list[str]
A list of breed names corresponding to the primitive of the agent being initialized. See
model — Helipad
The model object.
Expected Return Value — str
The breed to assign to the agent in question. Return value must be the name of a previously registered breed, or the function will raise a
ValueError. The function can return
None in which case Helipad will assign a breed using the default alternating logic.
Notes and Examples
charwickMar 22, 2020 at 21:29
In this model there are two breeds,
'rural', but we want the model to begin with all rural agents.
Or if we wanted to randomize breed assignment without worrying about strict equiproportionality,