Reference 〉 Function

Helipad.cutStep( )

When called from inside an agentStep or match hook, tells Helipad to skip stepping the rest of the agents that stage and proceed to the next (or to the next period in single-stage models). For example, in a model testing if any agent will succeed in a period, there is no need to step through further agents that period once one does, and the rest can be skipped.

In multi-stage models, cutStep proceeds to the next stage of the period. If cutStep() is called in a modelStep hook, no agents will be stepped that stage. The function has no effect in other hooks.

Notes and Examples

  1. charwick

    Jul 01, 2022 at 5:55

    In this model, all agents must succeed in order for the success condition to be met. If any agent fails, we can just skip to the next period.

    @heli.hook
    def agentStep(agent, model, stage):
    	agent.checked = []
    
    	#Choose the box with your own number, then choose the box with the number
    	#you find inside, and so on until you find your own number or run out.
    	agent.checked.append(model.boxes[agent.id-1])
    	while agent.id not in agent.checked and len(agent.checked) < 50:
    		agent.checked.append(model.boxes[agent.checked[-1]-1])
    
    	if agent.id not in agent.checked:
    		model.escaped = False
    		model.cutStep() #Go ahead and skip everyone else if anyone fails
  2. Contribute a Note

    Your email address will not be published.

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

History