Distance Functions


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": {
        "distance_function": "chebyshev"

        "search_radius": 10
    },
    ...
}

Options

Function NameBehavior
chebyshevThe greatest distance between two points in any axis also known as the L-infinity norm. Wikipedia
conwaySame as chebyshev. Named after John Conway because of its use in collecting all 8 neighbors in an agent's neighborhood.
manhattanDistance between agents are computed on a grid, where the distance is the total sum of the difference in each of the axes. Wikipedia
euclideanThe point-point distance "as the crow flies" between two points Wikipedia
euclidean_squaredSame as euclidean, but the final square root is not taken. This is useful when 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.

Previous