Reference 〉 Hook


In matching models, Helipad runs all matching groups through matchAccept. Return True to accept the match, and False to reject the match, in which case the matched agents return to the pool.

WARNING: Be careful that you do not write a situation where all remaining agents have matched and matchAccept returns False for the only remaining pair. The model will hang in this case. To actively select matches rather than reject random ones, use matchSelect.

Required Parameters

  • *agents list[Agent]

    The matched agents are passed as arguments to the function. If model.order=='match-3', for example, the function will take 3 arguments. Use *agent to get the agents as a list.

Expected Return Value bool

True to accept the match, False to reject it and return the agents to the pool.

Notes and Examples

  1. charwick

    Mar 28, 2020 at 1:10

    This example ensures that two agents of the same breed do not match.

    heli.order = 'match-2'
    def matchAccept(a1, a2):
    	return not a1.breed == a2.breed
  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.