Add ReplayIO: save/load replay data to/from replays/ directory#5
Closed
ScottWang05 with Copilot wants to merge 3 commits into
Closed
Add ReplayIO: save/load replay data to/from replays/ directory#5ScottWang05 with Copilot wants to merge 3 commits into
ScottWang05 with Copilot wants to merge 3 commits into
Conversation
Agent-Logs-Url: https://github.com/Meteony/COMP2113-G45-Group-Project/sessions/abddc09b-0186-4ec3-9e86-9bef6a62f012 Co-authored-by: ScottWang05 <206392236+ScottWang05@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Meteony/COMP2113-G45-Group-Project/sessions/abddc09b-0186-4ec3-9e86-9bef6a62f012 Co-authored-by: ScottWang05 <206392236+ScottWang05@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add functionality to save and load replay data from files
Add ReplayIO: save/load replay data to/from replays/ directory
Apr 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements file-based replay persistence via a new
ReplayIOclass, enabling match history to be written to timestamped files inreplays/and fully reconstructed from them.New files
include/core/replay_io.hpp—ReplayIOclass withReplayDatastruct (rows,cols,initialState,history) andsaveReplay/loadReplaystatic methodssrc/core/replay_io.cpp— Full implementation with format:Key correctness/robustness decisions
END_HEADERexplicit delimiter — avoids blank-line truncation bugsheaderFound && endHeaderFound,rows/cols > 0,actor ∈ {0,1}, and player positions within board bounds before constructingGameStateloadReplayfully restoresGameState: player positions,sideToMove,phase,statushistorycleared before loading to prevent stale-data accumulationstd::stoiwrapped intry/catch;localtime_rused overlocaltimelongforthinkTicksfields, consistent withTurnRecordModified files
Makefile—src/core/replay_io.cppadded to bothmanual_curses_matchandtest_main_menutargets.gitignore— added to exclude*.oartifacts and compiled binariesOriginal prompt
Save and load replay data to/from files in replays/ directory.
New Files
include/core/replay_io.hpp
src/core/replay_io.cpp