CS:GO Bot Behavior Trees

From Valve Developer Community
(Redirected from Mp bot ai bt)
Jump to: navigation, search
Counter-Strike: Global Offensive Level Creation

In Counter-Strike: Global Offensive Counter-Strike: Global Offensive , bots can be given a Behavior Tree to follow. A behavior tree dictates how the bot senses things (vision, hearing, damage sensing), moves, attacks, and does other actions.

They use Valve's proprietary KeyValues3 format (.kv3), which is a text-based format with somewhat strict syntax. They typically use the bt_ prefix, to signify that file is a Behavior Tree. They are stored in csgo/scripts/ai. One can create and use his own behavior trees, see below.

Officially, behavior trees are used for the game modes Csgo icon coopstrike.png Co-op Strike, Csgo icon guardian.png Guardian and Csgo icon deathmatch.png Deathmatch.

Behavior trees were first added to the game on September 16, 2019. Since September 1, 2020, behavior trees can be packed into BSP files.

Using a Behavior Tree

The ConVar mp_bot_ai_bt can assign a behavior tree to all bots on the server. Its value is a string representing the path to a .kv3 file, starting from csgo/. For example, the following line is used for official Deathmatch and can be found in csgo/cfg/gamemode_deathmatch.cfg:

mp_bot_ai_bt "scripts/ai/deathmatch/bt_default.kv3"

For the Co-op game mode, info_enemy_terrorist_spawn entities have the KeyValue behavior_tree_file that can be used to specify a behavior tree only for bots spawning at this entity.

Related Console Commands

ConVar Default Value Description
cv_bot_ai_bt_debug_target -1 Draw the behavior tree of the given bot.
cv_bot_ai_bt_hiding_spot_show 0 Draw hiding spots.
cv_bot_ai_bt_moveto_show_next_hiding_spot 0 Draw the hiding spot the bot will check next.
mp_bot_ai_bt "" Use the specified behavior tree file to drive the bot behavior.
mp_bot_ai_bt_clear_cache ConCommand Clears the cache for behavior tree files.


The first line of a .kv3 file is always a header specifying the KV3 version. For CS:GO, use this header:

<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->



Control Flow






Default Deathmatch Behavior Tree

Found in csgo/scripts/ai/bt_default.kv3.