24#include <SDL3/SDL_stdinc.h>
28#include <glm/vec3.hpp>
54 bool init(
const std::string& host, Uint16 port,
int botId);
71 void start(
const std::atomic<bool>& stopFlag);
89 [[nodiscard]]
bool isReady()
const {
return ready_.load(std::memory_order_relaxed); }
93 void runLoop(
const std::atomic<bool>& stopFlag);
209 std::uint32_t shotInputTick,
210 const glm::vec3& origin,
211 const glm::vec3& direction,
212 std::uint16_t intendedTargetClientId,
213 const glm::vec3& intendedTargetPos,
214 float intendedTargetDist,
216 std::uint16_t botHitClientId,
217 const glm::vec3& botHitPos,
TCP client for connecting to the game server.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
void setSimulatedLossPercent(int percent)
Apply a simulated UDP packet-loss percentage to the bot's UDP path.
Definition Bot.cpp:259
void join()
Block until the worker thread exits.
Definition Bot.cpp:325
std::FILE * obsCsv_
Definition Bot.hpp:168
void writeShotIntent(std::uint16_t shooterClientId, std::uint32_t shotInputTick, const glm::vec3 &origin, const glm::vec3 &direction, std::uint16_t intendedTargetClientId, const glm::vec3 &intendedTargetPos, float intendedTargetDist, bool botRayHit, std::uint16_t botHitClientId, const glm::vec3 &botHitPos, float botHitDist)
Append a shot-intent row.
Definition Bot.cpp:139
bool initialized_
True once init() succeeded; gates run().
Definition Bot.hpp:101
Registry registry_
Snapshot apply target — never read.
Definition Bot.hpp:96
void writeObservationLog()
Walk the registry for view<Position, ClientId>, write one row per replicated player entity to the bot...
Definition Bot.cpp:72
~Bot()
Definition Bot.cpp:41
int botId_
Log prefix.
Definition Bot.hpp:100
std::FILE * shotsCsv_
Definition Bot.hpp:189
std::thread thread_
Worker thread; joined in dtor or join().
Definition Bot.hpp:97
static constexpr int k_tickHz
Default tick rate; matches the server's physics tick rate.
Definition Bot.hpp:40
void setSimulatedLatencyMs(int totalMs)
Apply a simulated round-trip latency on the bot's UDP path.
Definition Bot.cpp:254
bool localPlayerReady_
Set true once localPlayerReadyFn fires for this bot.
Definition Bot.hpp:134
bool prevShootingForLog_
Rising-edge detector for fire log.
Definition Bot.hpp:190
bool isReady() const
PR-1: true once the bot's worker has logged at least one finished tick.
Definition Bot.hpp:89
uint32_t predictTick_
Monotonic tick counter, stamped onto each input.
Definition Bot.hpp:99
void runLoop(const std::atomic< bool > &stopFlag)
Worker-thread main loop: send input + poll, sleep to next tick.
Definition Bot.cpp:341
void closeObservationLog() noexcept
Flush + close the CSV if open. Safe to call from dtor.
Definition Bot.cpp:105
void openObservationLog()
Open the CSV if GROUP2_BOT_OBS_CSV_PREFIX is set.
Definition Bot.cpp:53
Bot & operator=(const Bot &)=delete
bool init(const std::string &host, Uint16 port, int botId)
Connect to the server.
Definition Bot.cpp:226
std::atomic< bool > ready_
PR-1 (server-perf): set true after the first successful poll inside runLoop.
Definition Bot.hpp:106
InputRingBuffer inputRing_
Definition Bot.hpp:128
void openShotsLog()
Open the shot-intent log if GROUP2_BOT_SHOTS_CSV_PREFIX is set.
Definition Bot.cpp:115
Bot & operator=(Bot &&)=delete
float getCurrentRttMs() const
PR-1 (server-perf): current smoothed RTT in ms.
Definition Bot.cpp:331
void start(const std::atomic< bool > &stopFlag)
Spawn the worker thread.
Definition Bot.cpp:264
Client client_
Underlying TCP client (TCP today; UDP after Phase 3).
Definition Bot.hpp:95
InputSnapshot input_
Reused per-tick input scratch.
Definition Bot.hpp:98
void closeShotsLog() noexcept
Flush + close the shot log if open. Safe from dtor.
Definition Bot.cpp:180
void setupLocalPlayerCallback()
PR-23: set up the onLocalPlayerReady callback that emplaces LocalPlayer + InputSnapshot + PreviousPos...
Definition Bot.cpp:209
TCP stream client — sends input to the server and receives state updates.
Definition Client.hpp:47