asobi_bot_spawner (asobi v0.84.0)
View SourceWatches the matchmaker queue and fills with bots when players are waiting. Also starts bot AI processes when bots join matches.
Bot names are read from the bot script's names global. If not defined,
falls back to default generated names.
add_bot/2 and remove_bot/2 are the other route in: a match script placing
a bot itself, rather than a mode opting in to queue fill. Queue fill answers
"not enough humans are waiting"; a script answers "this match wants a bot,
now", which is a question only the game can answer. They share the
?MAX_BOT_FILL ceiling, so a script cannot spawn processes without bound.
Both run here rather than in the match server because asobi_bot joins its
match from its own init/1: starting one from inside the match process would
block that process in supervisor:start_child/2 while the new bot waited on
it to answer the join.
Summary
Functions
Place a bot in a live match. Name is bare - the bot_ prefix every bot id
carries is added here, so a script never has to know about it.
Remove a bot from a live match, by bare name or by full bot_-prefixed id -
the roster a script reads holds the prefixed form, and a script that passes
back what it read should not have to strip it.
Whether Name is usable as a bot name, with the reason when it is not.
Functions
Place a bot in a live match. Name is bare - the bot_ prefix every bot id
carries is added here, so a script never has to know about it.
Silently does nothing if the match is gone, full, already holds a bot by that name, or is already at the bot ceiling; a script calling this on every tick must not turn into an error stream.
-spec handle_call(term(), gen_server:from(), map()) -> {reply, ok, map()}.
-spec init([]) -> {ok, map()}.
Remove a bot from a live match, by bare name or by full bot_-prefixed id -
the roster a script reads holds the prefixed form, and a script that passes
back what it read should not have to strip it.
Stopping the bot process is what removes it: asobi_bot:terminate/2 leaves
the match on the way out.
-spec start_link() -> gen_server:start_ret().
Whether Name is usable as a bot name, with the reason when it is not.