Distance Functions

How far away is one agent from another?

When finding the neighbors of agents in a simulation, HASH depends on a few important flags to produce accurate results. One such flag is the underlying distance calculations between agents in the simulation. These flags are accessible via topology configuration in properties. The topology field of your globals.json file will look something like:

{
"topology": {
// A global distance function agents use to localize
"distance_function": "chebyshev"
// A global search radius
"search_radius": 10
},
...
}

Options

Function Name

Behavior

chebyshev

The greatest distance between two points in any axis also known as the L-infty norm. Wikipedia

conway

Same as chebyshev. Named after John Conway because of its use in collecting all 8 neighbors in an agent's neighborhood.

manhattan

Distance between agents are computed on a grid, where the distance is the total sum of the difference in each of the axes. Wikipedia

euclidean

The point-point distance "as the crow flies" between two points Wikipedia

euclidean_squared

Same as euclidean, but the final square root is not taken. This is useful when for high-performance distance calculations when only order matters. Wikipedia

The default distance function is conway - make sure to change it depending on your use case!

Currently, HASH doesn't support multiple distance functions in a single simulation.