marcel123 Posted November 18, 2011 Report Share Posted November 18, 2011 I have just discovered 0 A.D. and starting poking around it. Congratulations to all the contributors. Great Effort!I wanted to get a better understanding of how the game behaves and wanted to study game replays. So, based on the existing "-replay" command, I implemented a quick and dirty "-visualreplay" command which renders the replay as it is playing back.When I record a two player multiplayer match, the visual replay is quite close to what happened during the original match. Howe\ver it is not identical. The general flow of the game seems identical and if you are not paying attention you might think that the replay was perfect. However it is not quite right. Unit positions are sometimes a bit off, sometimes different structures are destroyed, etc.Before I spent more time on it, I thought I would ask about the general state of the replay code and how robust it is considered. Also, I did not see any place where RNGs are seeded for the replays; is that something that could be causing issues?Thanks,Marcel Quote Link to comment Share on other sites More sharing options...
Ykkrosh Posted November 18, 2011 Report Share Posted November 18, 2011 The replay code should be perfectly robust in theory (i.e. it might have bugs, but I'm not currently aware of any). The game can output a hash of the simulation state into its recorded commands.txt (should do it by default in multiplayer; for single-player you'd have to enable it in CNetLocalTurnManager::NotifyFinishedUpdate), and CReplayPlayer::Replay will check those hashes (remove the "if (turn % 100 == 0)" line to make it go slower but report any divergence earlier), so that should tell you if the behaviour isn't replayed perfectly.If the hashes don't match then something is broken. To debug it, you'd need to enable m_EnableOOSLog in CSimulation2Impl::CSimulation2Impl, which will output the serialised state after every turn (into logs/sim_log/$PID/). Do that with the normal game where you're recording the commands, and again with the replay, and then find the first turn where the output differs and do a diff of the .txt files to see what part of the state is differing. Hopefully that'd indicate where to look The simulation RNG (CComponentManager::m_RNG) doesn't get seeded at all, so it should be consistent for every run. Quote Link to comment Share on other sites More sharing options...
marcel123 Posted November 21, 2011 Author Report Share Posted November 21, 2011 The hashes are different from the very first turn. I turned on m_EnableOOSLog, as suggested.On examining the resulting files, the first issue that I found was that when recording (multiplayer), the turn length was 500 but when replaying, the turn length was 200. On replay, it uses the default single player setting - hence the difference. When I fixed that, I have made it further, but am still seeing problems.For the first 5 turns, the serialized state for the recording and the replay is identical. On the 6th turn, they start differing. I don't really know enough about the code to have a good idea of what is going on and I am attaching the two states in case somebody might be able to give me a pointer as to what to look into.One odd thing is that even though the serialized state data is identical for the first 5 turns, the hash checking in Replay is reporting a hash mismatch on every single turn. When I look at the varios files, the following puzzles me:On Record the serialized state file for turn 1:State hash: 800d9bbe15bdd0ebc77eade6c20cb829On Replay the serialized state file for turn 1:State hash: 800d9bbe15bdd0ebc77eade6c20cb829The command.txt file: start {...}turn 0 200endhash f362a96697110a6b7d273c63400aa869turn 1 200endhash-quick 2c68ba6d1ff4cf925e0c8a8774787742turn 2 200endWarning generated in Replay():HASH MISMATCH (800d9bbe15bdd0ebc77eade6c20cb829 != f362a96697110a6b7d273c63400aa869)Turn 1 (200)... So it seems that the hash being calculated both during the record and the replay are identical and it is the hash that is being checked for by the test in Replay(), but the hash that was put into the command.txt file is somehow different.... Record00006.txtReplay00006.txt Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted November 21, 2011 Report Share Posted November 21, 2011 I don't see any problem when replaying a multiplayer or single player match (turn length shouldn't matter because that's just how fast the simulation ran). Maybe your visual replay is affecting the simulation. Can you provide the commands.txt file? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.