Debugging Errors


Overview

Errors can occur in simulations for lots of reasons. This page provides practical instructions for debugging simulations, and a quick-reference guide to some of the more common types of errors you may experience.

Debugging simulation errors

Debugging tutorial

Tips for debugging simulation errors:

  • You can use console.log() in JavaScript behaviors or print() in Python behaviors to output the value of a variable or an expression to the developer console (Ctrl+Shift+J on Windows, or Cmd+Option+J on Mac).
  • The Raw Output panel displays the full state of your simulation, which can be useful for figuring out what's going on. Keep in mind though it generates it for the last completed time-step - if your simulation has an error in the middle of a time-step the Raw Output panel will only show you the state that you entered the time-step with.
  • Often it's easiest to debug simulations with the bare minimum number of agents, to make it easier to track what's going on. Try reducing the number you create to simplify.
  • Please see the error reference below for explanations of commonly-experienced errors.

Common Errors

You may see a red error message pop up when running a simulation - here's some of the most common, and how to fix them.

Error Explanation

ReferenceError: behavior is not defined or


Can’t find variable: behavior

Every HASH behavior file must have a function signature with a function named behavior().


If it is not properly defined, you'll see this error.

ERROR running simulation: [error] did not match any variant of untagged enum OutboundMessage

All messages

must have a to and type field this error indicates the type is missing.

D is not a function.

Check analysis .json - this can indicate you referenced an output that doesn't exist or used an incorrect operation.

Agent "[agent id]" doesn't have a position.

Many operations on agents require a physical location on the x,y plane for example searching for neighbors. This error will be thrown if there is no position defined for the agent.

We're expanding this list with more errors, explanations, and fixes. If you encounter an error that is unclear, let us know.