Login

russian armor

Project for Parsing CoH1 Replay Data to Stream Overlay

4 Mar 2017, 01:34 AM
#1
avatar of r3ckonner

Posts: 6

Hello everyone!

In the midst of the CoH Will Never Die Tournament, I had a series of thoughts about improving the quality of the casts for future tournaments or even shoutcasts in general. While fumbling around with dyxstra's old COHRA (Company of Heroes Replay Analyzer) and looking at CoH2's spectator and replay modes, I was wondering if I can do something similar with CoH1.

I am not thinking about modding the game, but more of parsing replay data from the coh1 .rec files to perhaps a browser or an overlay program that can display information that would enhance the experience for casters and viewers alike. For example: if the American Player selected Infantry Company Doctrine at 5:23 min, the program would show that Infantry Company was selected when the replay reaches 5:23 min. Or at 45:12 min, when a riflemen squad was killed on retreat, the program would should a riflemen squad KIA. Maybe even show what both side's unit composition looks like or show player commands used.

However, I do not know the details of how the replay data is structured (such as how exactly does CoH time stamps actions in the replay). Is there anyone I can get in touch with who may be able to help me out?

Thank you in advance,

R3ckonner
Seb
6 Mar 2017, 21:29 PM
#2
avatar of Seb
Admin Black Badge

Posts: 3709 | Subs: 2

Hello,

To complete what I told you on my PM and answer specific points raised on this message:

For actual live spectator there have been attempts with modded game and modded maps. Nothing is supported from the game itself except just being in-game (as player), or viewing a replay solo. It's theoretically possible to hack the game or to create a 3rd party app to sync multiple clients on the same replay time. Not sure if it has been done, or if it's even worth it.

Doctrine selection and time is very easy from the replay file because it's an irreversible one time action.

Units killed is impossible from the replay file, because it is not written and it directly depends on the simulation done by the game engine. Unless being able to recreate the simulation of the game engine entirely... Or again to hack the game to listen to that information directly from the in-game memory/events.

Same problem for showing the units on both side...

As for the commands used, it will work, except you won't have the result of the command.

If you see clicks on the map, you don't actually know where units are without taking into account the map itself, path finding, combat, retreats, ... from the start of the game to the end.

If you see multiple units are queued on buildings, you need to simulate the building time, check there was no command to cancel the build, simulate the game to know the building wasn't destroyed, etc, etc before even being able to decide that the unit arrived on the map...

Or you can just make something approximate and only take into account the usual cases.


So basically half of what you want might be directly on the replay file, and for the other half it's probably impossible, unless recreating a perfect simulation of the game engine (from scratch or based on the game files), which either way doesn't sound realistic to do at all. At that point it's probably easier to "just" create a hack to the game memory to grab the required info...


And for those who didn't get the PM:

Time is in there, it's based on ticks 1/8 of a second if I remember. It's just an incremental number that you multiply to get time. It should be one of the first blocks of data before the actions.

You can look there for Inverse's coh2 parser we use on the site (actions didn't change much I believe): https://github.com/ryantaylor/vault

Source for a coh1 parser (I don't remember in which state it is but probably functional or close enough): https://www.gamereplays.org/community/index.php?showtopic=813678
7 Mar 2017, 18:49 PM
#3
avatar of r3ckonner

Posts: 6

Hi Seb,

Thank you for the response. So the units' state are actually simulated in game. Does the replay store data to make sure that random RNG moments are recorded and reproduced when the replay is played?

Where in the replay data does the actually replay stop? As in where does it end?

Thank you again.
7 Mar 2017, 22:30 PM
#4
avatar of Siphon X.
Senior Editor Badge

Posts: 1138 | Subs: 2

Hi Seb,

Thank you for the response. So the units' state are actually simulated in game. Does the replay store data to make sure that random RNG moments are recorded and reproduced when the replay is played?

Where in the replay data does the actually replay stop? As in where does it end?

Thank you again.


Assuming that coh1 replays work like coh2 replays (and Seb´s description sound like it does):

Every computer RNG is actually only a pseudo-RNG. You have to "seed" the generator with a number. Seeded with the same number, you´ll get the same sequence of "random" number. The replay files do contain that seed, so when replaying the replay, each event that requires some RNG role will give the same result as when the game was played originally. Like, the units will hit, miss and penetrate like they did originally.

After some header, the replay basically contains only the commands of the players. So, the replay file ends when the players stop issuing commands. This also means that the file does not even contain explicitly why a game ended and who won. That is, unless one of the players issued the "surrender" command, which is stored in the replay as well.
9 Mar 2017, 18:48 PM
#5
avatar of r3ckonner

Posts: 6



Assuming that coh1 replays work like coh2 replays (and Seb´s description sound like it does):

Every computer RNG is actually only a pseudo-RNG. You have to "seed" the generator with a number. Seeded with the same number, you´ll get the same sequence of "random" number. The replay files do contain that seed, so when replaying the replay, each event that requires some RNG role will give the same result as when the game was played originally. Like, the units will hit, miss and penetrate like they did originally.

After some header, the replay basically contains only the commands of the players. So, the replay file ends when the players stop issuing commands. This also means that the file does not even contain explicitly why a game ended and who won. That is, unless one of the players issued the "surrender" command, which is stored in the replay as well.


I see. However, what is exactly is the start header? Are the ticks variable depending on the replay or are they the same, but can be masked by player commands in the replay?
10 Mar 2017, 08:34 AM
#6
avatar of Siphon X.
Senior Editor Badge

Posts: 1138 | Subs: 2



I see. However, what is exactly is the start header? Are the ticks variable depending on the replay or are they the same, but can be masked by player commands in the replay?


I can't say much about the header. I didn't really look into the replay files itself, only it's interpretation that comes out of inverse's vault. And all of that on coh2 replay files, never dabbled into coh1, no idea how similar they are.

The coh2 headers contain stuff like player names, map, commander and bulletin loadout, start and end time of the match in Unix time and the RNG seed.
Seb
10 Mar 2017, 18:24 PM
#7
avatar of Seb
Admin Black Badge

Posts: 3709 | Subs: 2

COH2 header got more stuff added to it over time after some requests we made to Relic that they gracefully implemented.

COH and COH2 replays are very similar, not always, but except few structural changes, it's usually just that COH has less info.

The best way to figure it out is to look at the existing parsers.

The header is everything before the commands... It does contain the match info, players info, map info, ... Including the RNG seed. However the seed is completely useless without the full game engine, since you need to know how the seed is used to calculate the numbers, which depends entirely on their code. It probably depends on time and/or also probably depends on how many other RNG calls have been made up to a certain point in the game. So for us I consider it meaningless for all intents and purposes. I know for sure they don't just seed an existing number generator, they do have their own generation code created in the 90s from their older games, and always kept it, or something along those lines.

This is why I said that to simulate the game based on the replay to extract any meaningful info is to recreate the whole game engine to the most insignificant detail. I would definitely consider it easier to create an actual hack to read from the game memory while the replay is playing.


To answer the few questions:

No, the replay doesn't store the result of the RNGs, it's all based on the non exploitable seed (as I explained, this is in practice, because in theory it is possible).

From the replay data only it's impossible to know when the game is over, or who won the game in COH1. This has always been the most significant issue of any replay tool, replay section, automated tourney result validation, or any other data mining possibility.

For the ticks I don't remember exactly, but I think there is a tick in the replay every time there is a command that tick (and there could be multiple commands per tick too). If no command has been given that tick, it could be either that the tick is missing, or is present but empty. It's just an implementation detail, the best is to look at the parsers.
1 user is browsing this thread: 1 guest

Ladders Top 10

  • #
    Steam Alias
    W
    L
    %
    Streak
Data provided by Relic Relic Entertainment

Replay highlight

VS
  • U.S. Forces flag cblanco ★
  • The British Forces flag 보드카 중대
  • Oberkommando West flag VonManteuffel
  • Ostheer flag Heartless Jäger
uploaded by XXxxHeartlessxxXX

Board Info

649 users are online: 649 guests
0 post in the last 24h
12 posts in the last week
26 posts in the last month
Registered members: 49851
Welcome our newest member, Eovaldis
Most online: 2043 users on 29 Oct 2023, 01:04 AM