# Robot Behaviors

A robot behavior can be defined as any action that the robot can perform. It can be helpful to think about robot behaviors in terms of their **type** (purpose) and **level** (complexity).

## Types of Robot Behaviors

Robot behaviors can also be categorized into different types based on their purpose. This guidebook has grouped robot behaviors into the following categories:

* [Producing Alerts](/code-robotics/references/robot-behaviors/producing-alerts.md)
* [Driving](/code-robotics/references/robot-behaviors/driving.md)
* [Turning](/code-robotics/references/robot-behaviors/turning.md)
* [Detecting Objects](/code-robotics/references/robot-behaviors/detecting-objects.md)
* [Detecting Lines](/code-robotics/references/robot-behaviors/detecting-lines.md)
* [Detecting Other Conditions](/code-robotics/references/robot-behaviors/detecting-other-conditions.md)

There are other types of behaviors **not** included in this guidebook that you could program your robot to perform. For example, you could program your robot to [solve mazes](https://www.instructables.com/id/Robot-Maze-Solver/), etc.

## Levels of Robot Behaviors

Robot behaviors can generally be categorized into different levels of complexity:

* **Basic Behaviors** – these are low-level behaviors that perform a single action, such as: turning on the motors, reading a sensor, etc. In a robot app, basic behaviors can be performed with a single code statement.
* **Simple Behaviors** – these are mid-level behaviors that perform a simple task, such as: driving forward for 5 seconds, turning to the right, etc. A simple behavior consists of a sequence of basic behaviors. In a robot app, simple behaviors require several code statements.
* **Complex Behaviors** – these are high-level behaviors that perform a complex task, such as:  following a line, driving around an obstacle, etc.  A complex behavior consists of a sequence of simple behaviors. In a robot app, complex behaviors require many code statements, which are often put into a custom function.

The value of thinking about different levels of robot behaviors is to simply recognize that behaviors can combined (or broken down) into other behaviors:

* **Composition:**  Lower-level behaviors can be combined into a sequence that produces a more complex behavior.
* **Decomposition:**  A higher-level behavior can be broken down into a sequence of more simple behaviors.

Understanding composition and decomposition can help you plan out the structure of your robot's program and figure out how to program the higher-level behaviors that you need to demonstrate your task scenarios.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.idew.org/code-robotics/references/robot-behaviors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
