R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
bot_options.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <rtype/bot.hpp>
6
7#include <cstdint>
8#include <filesystem>
9#include <optional>
10#include <span>
11#include <string>
12#include <string_view>
13#include <variant>
14
15namespace rtype {
16
18inline constexpr std::string_view bot_usage =
19 "usage: r-type_bot [--host <address>] [--port <tcp port>] [--name <player name>]\n"
20 " [--count <bots>] [--inputs <script file>] [--seconds <play time>]\n"
21 " [--seed <number>] [--stats <csv file>] [--help] [--version]\n";
22
24inline constexpr std::uint32_t max_bots = 64;
25
27enum class BotCommand : std::uint8_t {
29 Run,
31 Help,
33 Version,
34};
35
37struct BotOptions {
43 bool seeded = false;
45 std::optional<std::uint32_t> seconds;
47 std::uint32_t count = 1;
50 std::optional<std::filesystem::path> inputs;
53 std::optional<std::filesystem::path> stats;
54};
55
64[[nodiscard]] std::variant<BotOptions, std::string>
65parse_bot_options(std::span<const std::string_view> args);
66
67} // namespace rtype
A player without a window: joins a server and holds random or recorded inputs.
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
BotCommand
What the bot was asked to do.
Definition bot_options.hpp:27
@ Run
Join the server and play.
@ Version
Print the version and exit.
@ Help
Print the usage and exit.
@ Run
Start the game and listen on the ports.
constexpr std::string_view bot_usage
Usage line printed by --help and after a command line error.
Definition bot_options.hpp:18
std::variant< BotOptions, std::string > parse_bot_options(std::span< const std::string_view > args)
Reads the command line of r-type_bot.
constexpr std::uint32_t max_bots
Most bots --count runs in one process.
Definition bot_options.hpp:24
Settings of a bot run, read from the command line.
Definition bot_options.hpp:37
std::uint32_t count
--count: number of bots, 1 to max_bots, named and seeded by bot_team().
Definition bot_options.hpp:47
std::optional< std::filesystem::path > stats
--stats: CSV file written at the end, one line per bot that played (bot_stats_header,...
Definition bot_options.hpp:53
BotCommand command
What to do; the settings only matter for BotCommand::Run.
Definition bot_options.hpp:39
std::optional< std::uint32_t > seconds
--seconds: leave after playing this long; nothing plays until Ctrl+C.
Definition bot_options.hpp:45
bool seeded
--seed was given: otherwise each run draws its own.
Definition bot_options.hpp:43
BotSettings settings
Server, name (bot by default) and seed.
Definition bot_options.hpp:41
std::optional< std::filesystem::path > inputs
--inputs: script replayed by every bot instead of random inputs, read with load_input_script().
Definition bot_options.hpp:50
What a bot needs to join a server.
Definition bot.hpp:54