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>
22 lines
919 B
C++
22 lines
919 B
C++
#pragma once
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
struct Command;
|
|
|
|
// Serializes a command to a single-line, space-delimited token sequence for the
|
|
// replay file (see docs/replay_design.md "File format: line-oriented ...").
|
|
// Config ids (building types, recipes, items, modules) are whitespace-free
|
|
// identifiers, so space delimiting is unambiguous; variable-length parts are
|
|
// length-prefixed so the matching parser (added in Phase 3) is unambiguous.
|
|
//
|
|
// Reset is a file boundary (it rolls the replay file), not a stream entry, so it
|
|
// is never serialized here.
|
|
std::string serializeCommand(const Command& command);
|
|
|
|
// Inverse of serializeCommand: parses the command token sequence (the part of a
|
|
// replay line after the leading tick) back into a Command. Returns nullptr if the
|
|
// tokens are malformed or reference an unknown building type.
|
|
std::shared_ptr<Command> parseCommand(const std::string& tokens);
|