Page 1 of 1

Combat analytics

Posted: Sat Aug 27, 2016 7:37 pm
by lucassss
I've been helping Noit with some testing of the Shattered Paradise mod and I had the idea to see which units are dangerous to who. Turns out that all it takes is changing 2 lines in the source code of OpenRA and you can get that info dumped into a debug file and later analyzed but another python program I wrote.

This allowed me to analyze a replay and get results like this (dots are inserted to prevent clutter):

--- THREE TOP EASY KILLS FOR EACH ---
dino: ('harv', 1340),('mutfiend', 827),('muradr', 520)
visc_lrg: ('cyborg', 450),('worker', 120),('mupowr', 60)
.
.
.
cyborg: ('marauder', 2023),('mutfiend', 1580),('gacnst', 1505)
.
.
.

From this one you can see that cyborgs were the most effective against marauders and against fiends, and that dinos were mostly useful for attacing harvs.

Is anyone interested in something like this for OpenRA? I'd gladly send my code to everyone who is interested, it is really only a few lines.

Posted: Sat Aug 27, 2016 7:44 pm
by Murto the Ray
I could make a script for this which could be attached to maps quite easily with the added benefit of working right now :)

Posted: Sat Aug 27, 2016 9:11 pm
by lucassss
Can a lua script dump lots of data to a file? The whole idea is that we don't know in advance what to analyze, so we just record every time something damages something and then run an analyzer program on the report. What I showed is the output of the analyzer, but every damaging hit is saved.

Also, the nice thing is that you can run this on replays to see how things went in the game.

Posted: Sat Aug 27, 2016 10:59 pm
by Graion Dilach
I'd take a look to the diff, yes.

Posted: Sun Aug 28, 2016 5:23 am
by Canavusbis
lucassss wrote: Can a lua script dump lots of data to a file? The whole idea is that we don't know in advance what to analyze, so we just record every time something damages something and then run an analyzer program on the report. What I showed is the output of the analyzer, but every damaging hit is saved.

Also, the nice thing is that you can run this on replays to see how things went in the game.
The Lua sandbox has been designed to prevent maps from accessing IO and other system utilities, so no.

However, a custom patch can be made for each release in order to add non-standard client-side features, if it doesn't get merged upstream. This could be done in two ways: a custom build or a mod.

Posted: Sun Aug 28, 2016 6:04 am
by Murto the Ray
Canavusbis wrote:
lucassss wrote: Can a lua script dump lots of data to a file? The whole idea is that we don't know in advance what to analyze, so we just record every time something damages something and then run an analyzer program on the report. What I showed is the output of the analyzer, but every damaging hit is saved.

Also, the nice thing is that you can run this on replays to see how things went in the game.
The Lua sandbox has been designed to prevent maps from accessing IO and other system utilities, so no.

However, a custom patch can be made for each release in order to add non-standard client-side features, if it doesn't get merged upstream. This could be done in two ways: a custom build or a mod.
Actually, if you use print it will output into the lua log.

Posted: Sun Aug 28, 2016 11:38 am
by lucassss
http://pastebin.com/FCXPcbaW - Patch to modify OpenRA
http://pastebin.com/7iNXuuXB - Utility to analyze debug.log (I use command line '<' to make it input)

The whole idea to extend the analysis utility as much as we want. For example, the next thing I want to add is information about damage effectiveness. I.e. how many times did a unit target an armor class that wasn't its best class.

Posted: Sun Mar 26, 2017 3:24 pm
by Matt
The idea is good to generate hard data to improve balancing. You shouldn't patch the Health.cs as it is part of core engine. Write an IUtilityCommand to extract this from the replay. Otherwise this stays a quick hack that can't be added.

Posted: Sun Mar 26, 2017 7:04 pm
by crlf
Are the replays themselves in a format parseable by anything other than OpenRA?

Posted: Sun Mar 26, 2017 8:20 pm
by Matt
The metadata header should be easy to parse. That is what sites like https://www.gamereplays.org/openra/ do. However the actual gameplay, which is just a binary stream, is better parsed by the game functions itself.

Posted: Mon Mar 27, 2017 12:58 am
by Kwendy
Don't forget to share your findings, oh ye who tried this code.