Add deterministic record/playback for a run. Recording captures `(seed, config hash, ordered tick-tagged commands)` and re-simulates on playback — no state snapshots. `DotaFactory.exe --replay <file>` re-plays a recorded run view-only with manual speed/pause. Reviewed-on: #4 Co-authored-by: Malte Langkabel <malte.langkabel@gmail.com> Co-committed-by: Malte Langkabel <malte.langkabel@gmail.com>
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Tick.h"
|
|
|
|
struct Command;
|
|
|
|
struct ReplayHeader
|
|
{
|
|
int version = 0;
|
|
std::string build;
|
|
unsigned int seed = 0;
|
|
std::string configHash;
|
|
std::string timestamp;
|
|
};
|
|
|
|
// One entry of the replay stream: either a command (applied at its tick) or an
|
|
// RNG checksum (verified at its tick). Entries are kept in file order, which is
|
|
// the canonical order the playback driver reproduces.
|
|
struct ReplayEntry
|
|
{
|
|
Tick tick = 0;
|
|
bool isCommand = false;
|
|
std::shared_ptr<const Command> command; // set iff isCommand
|
|
std::uint64_t fingerprint = 0; // set iff !isCommand
|
|
};
|
|
|
|
struct ParsedReplay
|
|
{
|
|
ReplayHeader header;
|
|
std::vector<ReplayEntry> entries;
|
|
};
|
|
|
|
// Parses a replay file (header + command/checksum stream). Returns nullopt on an
|
|
// I/O failure or malformed content (e.g. an unparseable command line).
|
|
std::optional<ParsedReplay> readReplayFile(const std::string& path);
|