Bots

What a bot is

Bots are players that live on the server. They join, spawn, shoot, dig and build through the same paths as a client, and the server validates every action the same way: a wall costs real blocks, digs respect the spade’s delays, a hit needs a real ray. A bot has no network connection and appears on the scoreboard like anyone, with the name Bot_ plus two words (Bot_SwiftFox).

Note Bots only play while at least one human is in the match (waiting to respawn, respawning or ready). With nobody in, they exist and stand still, and the log says Bots paused. SP_BOTS_PLAY=1 lets them play alone, for tests and benchmarks.

This chapter is what an owner needs. How the bots decide in detail (senses, fighting, routes, roles) is in docs/bots.md how a plugin or a Lua game mode steers them is in Game modes and bots in Lua.

Adding bots

NameTypeMeaning
--bots <n>optionStart with n balanced bots.
--team-bots <a> <b>optionStart with a bots on team 1 and b on team 2. The shipped maps have defaults of 10 a team where the bases are close and 20 on the large ones.
--bots-testoptionOne strong enemy bot on the human's own spawn: the fastest way to test combat.
/addbot [n] [blue|green]commandAdds bots to a team (or balanced). Role: everyone, unless the server restricts it.
/autofill <n>commandKeeps n players in the match: as humans join, bots leave, and the reverse. A count alone does not switch it on in the host's menu until its box is ticked.
/botfill <n>commandTops both teams up to n players each.
/botscommandShows bot, human and autofill counts.
/kickbot <id>, /kickbotscommandRemoves one bot by id, or all of them.
host menuclientA player hosting a game from ngspades-client changes team counts, difficulty and autofill from the pause menu ("Bots"). The contract is in `docs/host-commands.md`.

Autofill (and “keep the match full”) trims bots when humans arrive; it frees them only at a human’s spawn, never inside the loops that walk the player list.

How well they play

[bots]
difficulty = "normal"      # easy, normal, hard
LevelSkill rangeFeel
easy0.05 - 0.35Rookies. Aim error x1.5: barely hit beyond 10 blocks.
normal0.15 - 0.90Poor shots: about 55% of hits at 10 blocks, 25% at 20, 10% at 30.
hard0.60 - 0.95Good players, still no aimbots. Aim error x0.6.

Each bot rolls its own skill in the range when it spawns; skill drives aim error, reaction time (0.45 s for the weakest, 0.15 s for the best), dodge rhythm and how many shots are wasted. SP_BOT_DIFFICULTY and a preset’s bot_difficulty override the config; the host’s menu changes it during a match. The --bots-test bot keeps a fixed skill of 0.9.

What they do

Bots and performance

The planner runs on its own thread and never on the tick. Measured on an Apple M4 with 127 bots on a large map: 60 ticks a second, 0.6-0.7 ms a tick on average, 5-8% of one core, about 76 MB of memory. A think over 5 ms logs bot_slow with what it was doing, and a tick over 20 ms logs Slow tick: with the parts. SP_BOT_* variables (see the environment table) switch single behaviours off for a measurement.

Bots in the logs

With SP_EVENTLOG=1, bots log as bot3:Bot_SwiftFox actors: bot_goal, bot_nav action=plan|lost|blocked, bot_shot result=miss|head|torso|legs, bot_cover, bot_wall, bot_fort, bot_perch, bot_jet… A bot that wanders off the map’s edge stops at it; a bot in the water swims to a shore it can climb. A server that reports bot_path action=stuck often has a map the bots cannot read; report it with the map’s name.