Skip to main content

Terrain Height

Returns the height of the terrain the agent is currently on.

Terrain Height block

Description

The Terrain Height block returns the height of the terrain the agent is currently on. This is a code block part of the Environment drawer.

Usage

Use Terrain Height to detect terrain elevation at the agent's position. This block is essential for collision detection with walls, navigation over varied terrain, or triggering behaviors based on elevation changes.

Syntax

Inputs:

  • None

Example

When setup is pushed, walls of height 10 are built dividing the molecules into 4 areas. To keep them isolated the terrain height block is used to make the molecules turn around when the terrain height they are located in is equal to 10 which happens whenever they run into a wall.

Terrain Height example code

Notes

  • Returns a numerical value representing the terrain elevation at the agent's exact position
  • Useful for implementing collision detection with terrain features
  • Can be used in conditional statements to trigger different behaviors