• Log InLog In
  • Register
Liquid`
TeamLiquid Liquipedia LiquidDota LiquidLegends
EDT 16:31
CEST 22:31
KST 05:31
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL14] Ro24 Preview Pt2: Speedrunning6WTL 2022 Summer - Playoffs Preview4Farewell CCL: Season 4 Recap1WTL 2022 Summer - Regular Season Awards + Week 119[ASL14] Ro24 Preview Pt1: Long Awaited15
Community News
[TSL 9] TIME's replacement, UK Barcrafts31ESL Open Cup #135: ByuN, MaxPax, Solar win5Code Season 3 (2022) - RO20 groups announced70GSL S3 2022 Qualifier Cast (AfreecaTV)3Team NV to disband after WTL 2022 Summer26
StarCraft 2
General
[TSL 9] TIME's replacement, UK Barcrafts Code Season 3 (2022) - RO20 groups announced PvZ and creep What are your feelings on the new SC2 map pool? ESL Open Cup #135: ByuN, MaxPax, Solar win
Tourneys
Sniper's Team League Season 1 HomeStory Cup 21 SC2 Tournament Forum Posting Tips Announcing $5,000 G-FUEL Gladiators' Cup GSL S3 2022 Qualifier Cast (AfreecaTV)
Strategy
PvT macro builds Terran Mule Timing wankery What should I try to work on to improve my TvZ Maru Offensive Widow Mine Drop
Custom Maps
[A] SC Real Scale Alternate Melee | Extension Mod – Multiplayer LotV [M](4) Typhoon StarLance | Extension Mod – Multiplayer LotV
External Content
Mutation # 330 Ulnar New Year Mutation # 329 Attrition Warfare Mutation # 328 Overclocked Mutation # 327 Temple of Rebirth
Brood War
General
BGH auto balance -> http://bghmmr.eu/ The future of starcraft broodwar Starcraft University [ASL14] Ro24 Preview Pt2: Speedrunning BW General Discussion
Tourneys
[ASL14] Ro24 Group F [ASL14] Ro24 Group E New Worlds Map Contest 2: Test Tours! [ASL14] Ro24 Group D
Strategy
Battery control PvT advise for noobs [PvP] How to defend vs. 2 gate zealot into nexus Project: Strat Update
Other Games
General Games
Final Fantasy XIV Diablo IV Company of Heroes 3 Nintendo Switch Thread Pokémon Go!
Dota 2
Official Dota and Chess General Discussion PGL Arlington Major [DPC 21-22] Tour 3 Discussion/LR TL.net migration megathread + LiquidDota archive
League of Legends
[Summer Split] LoL Esports General Discussion [Patch Notes] Release General Discussion
Heroes of the Storm
HotS: WP and Funny Moments Farewell CCL: Season 4 Recap Time of the Season: X-Cup Summer Preview The New Kings of Paris: MCC Finals Recap
Hearthstone
TL Mafia
Chezinu streak(s) Mafia TL Mafia Community Thread British Empire Mini Mafia II
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread UK Politics Mega-thread Coronavirus and You South American Politics thread
Fan Clubs
The Flash Fan Club The herO Fan Club! INnoVation Fan Club
Media & Entertainment
[TV] HBO's Westworld Korean Music Discussion Movie Discussion! Anime Discussion Thread [Manga] One Piece
Sports
2022 - 2023 Football Thread McBoner: A hockey love story NBA General Discussion Formula 1 Discussion 2021 - 2022 Football Thread
Tech Support
The Ultimate Mouse Thread Computer Build, Upgrade & Buying Resource Thread Windows won't boot from cloned SSD
TL Community
The Automated Ban List
Blogs
Some New Pilot Certificat…
micronesia
U.S. Remote Job Opportunity…
FrinkX
Namkraft's ASL 14 ENG casts…
namkraft
Regarding teenagers and …
mantequilla
New EG Roster
cmsimon
Programming Without Addera…
codonbyte
Royal Tyrell Museum in Drumhe…
JimmiC
Great mix of RTS and tu…
AiHEADHUNTER
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1452 users

s2gs file -- a fun little mystery for us

Forum Index > SC2 General
Post a Reply
1 2 3 4 5 6 7 Next All
dsjoerg
Profile Joined January 2012
United States384 Posts
April 20 2012 21:00 GMT
#1
hi TL nerds,

a lot of people have been asking over the years if we could figure out a way to get Spending Quotient and other interesting stats about our matches. there is an interesting file that i believe contains all the stats that are shown in the Summary Screen after a game completes.

it's the s2gs file. You can trigger arbitrary *.s2gs files to be downloaded to your machine by viewing game summaries in the SC2 client. In SC2, go to your Match History, then click on one of the magnifying glasses. That will trigger a new s2gs file to be downloaded to your machine.

On my Mac, they're in paths like this:
/Users/Shared/Blizzard/Battle.net/Cache/69/61/6961b3a6c6c294dbff91a786d60fddea962e70b01a040a5c7a096987896a2e0e.s2gs


On PCs I'm told they are here:
C:\ProgramData\Blizzard Entertainment\Battle.net\Cache


The easiest way to find a s2gs file is to look at some match summary screen in the game client, then go to the directory and sort by date modified.

If we all put our heads together, I bet we can figure out the format.

A fellow SC2 nerd, Nick, was able to get this far:

#!/usr/bin/env python

import zlib

data = open("test.s2gs","rb").read()

print zlib.decompress(data[16:])


Some of you may wonder about what Blizzard's reaction to this project will be. I hope that Blizzard will have the same reaction that they've had to the community's study of the structure of the MPQ and the replay format -- essentially none. Of course, if Blizzard prefers that this project not move forward, I for one will cease immediately.

I'm not sure what's the best way to structure our findings -- I guess people can post what they discover in this thread, and once that becomes unwieldy, someone can set up a wiki or public Google docs page to hold the findings. Or a github project.

You might be asking, what's the point of being able to parse s2gs files? Basically every tool that does anything useful with replays could parse s2gs as well, and all the info that is visible in the end-of-game summary screen could be merged with the replay info. For example, computing Spending Quotient would be trivial. There are about 30 other cool things would be immediately quite doable.
card-carrying grubby fan. developer of GGTracker.
Kralic
Profile Blog Joined March 2010
Canada2628 Posts
April 20 2012 21:04 GMT
#2
I am not sure what to say... so I will say good luck decrypting the encrypted file.
Brood War forever!
Monokeros
Profile Blog Joined November 2005
United States2493 Posts
April 20 2012 21:04 GMT
#3
This would be all kinds of amazing seeing this kind of information more power to you sir.
Keep the Dream Alive twitch.tv/monokerros
TelecoM
Profile Blog Joined January 2010
United States10580 Posts
April 20 2012 21:07 GMT
#4
Sounds interesting but I don't even understand what you are saying to be honest, hope it works out for you.
AKA: TelecoM[WHITE] Protoss fighting
spancho
Profile Joined September 2009
United States161 Posts
April 20 2012 21:15 GMT
#5
On April 21 2012 06:04 Kralic wrote:
I am not sure what to say... so I will say good luck decrypting the encrypted file.


I dont think its encrypted, just compressed. This seams like a cool project, but I cant think of anything you can get from the summery that you couldnt get from the replay file. Just easier parsing perhaps?
"Your face can't hurt 'cuz you're ugly." -Tasteless
dsjoerg
Profile Joined January 2012
United States384 Posts
April 20 2012 21:19 GMT
#6
spancho, the summary has a lot of things you can't get from the replay, for example:
* average unspent resources
* resource collection rate
* number of workers created
* first 64 things built by each player

each of these can be estimated from the replay, but in many cases the estimation will be off, sometimes by a lot.

the replay file contains build commands that fail due to lack of resources, and there's no way to tell which these are without recreating the whole game engine. unspent resources also cannot be calculated without essentially rebuilding the game engine.

also the replay file doesnt tell you when workers are killed. when my workers die it can change my resource collection rate a lot
card-carrying grubby fan. developer of GGTracker.
InfCereal
Profile Joined December 2011
Canada1691 Posts
April 20 2012 21:21 GMT
#7
On April 21 2012 06:15 spancho wrote:
Show nested quote +
On April 21 2012 06:04 Kralic wrote:
I am not sure what to say... so I will say good luck decrypting the encrypted file.


I dont think its encrypted, just compressed. This seams like a cool project, but I cant think of anything you can get from the summery that you couldnt get from the replay file. Just easier parsing perhaps?


It would be a way to get spending quotient without relying on a sketchy text recognition script.
Cereal :: AllThingsZerg.com :: SC2Overwatch.com
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
Last Edited: 2012-04-21 13:07:00
April 21 2012 13:05 GMT
#8
Would you care to upload a decompressed version of an s2gs file?

I keep getting an "input string does not conform to zlib format" when trying to do this myself...

Edit: nvm, got it working now.
Prillan
Profile Joined August 2011
Sweden350 Posts
April 21 2012 13:19 GMT
#9
This is really interesting. I've found some things and will continue trying to understand it. I will "publish" my findings here: (Wiki)User:Prillan/s2gs
TheBB's sidekick, aligulac.com | "Reality is frequently inaccurate." - Douglas Adams
zyce
Profile Blog Joined March 2011
United States649 Posts
Last Edited: 2012-04-21 13:32:46
April 21 2012 13:30 GMT
#10
I'm not sure this file has complete data, I'm only seeing reference points (game speed, difficulty, players) and no game data such as resources/workers.

It would be nice to chat with some others who are working with this data. I'm in #teamliquid on IRC.

Edit(s): zlib 1.2.5 being used instead of 1.2.6.
Beauty is not the goal of competitive sports, but high-level sports are a prime venue for the expression of human beauty. The relation is roughly that of courage to war.
zyce
Profile Blog Joined March 2011
United States649 Posts
April 21 2012 14:20 GMT
#11
After some further discussion, I believe this might be a red herring. A file containing reference points needed to parse the relevant packets coming from Battle.net, which are consumed by the replay scoreboard to populate variables.

Beauty is not the goal of competitive sports, but high-level sports are a prime venue for the expression of human beauty. The relation is roughly that of courage to war.
RobiTL
Profile Joined July 2010
France55 Posts
April 21 2012 17:05 GMT
#12
I added some things to your liquipedia page (including the 2 lines required in PHP to read and decompress the file)
Born to be Zerg
dsjoerg
Profile Joined January 2012
United States384 Posts
April 21 2012 21:30 GMT
#13
I believe the s2gs file is actually the concatenation of a few different logical files.
card-carrying grubby fan. developer of GGTracker.
RobiTL
Profile Joined July 2010
France55 Posts
Last Edited: 2012-04-22 00:54:05
April 22 2012 00:23 GMT
#14
Ok I'm 100% sure there is all the data that we want :D

Values as stored as the double !

0x28 => 40 => 20
0x50 => 80 => 40
0xF001 => 240+0 =>120
0x9802 => 152+1*128 => 280
0xc002 => 192+1*128 => 320
0x9003 => 144+2*128 => 400
0xe003 => 224+2*128 => 480
General rule : YY1 YY2 gives (YY1 + (YY2 - 1) * 128) / 2



Graph data is like this :
02 04 00 04 09 [XX] 05 06 00 09 [YY1 YY2 YY3 ...]
XX is X coordinates 00,02,04, ...,3C
YY is Y coordinate as stated above.

average unspent resource is preceded by 05040009ce0f02090802001e00
Ressource collection rate is preceded by 05040009ce0f02090a02001e00

05040009ce0f02090a02001e00 ==> ressource collection rate
0205060009 f018 02040004099a1300 => player 1's = f018
0205060009 ba1e 02040004099a1300 => player2's = ba1e
0000 3's
0000 4's
0000 5's
0000 6's
0000 7's
0000 8's
0000 9's
0000 10's
0000 11's
0000 12's
0000 13's
0000 14's
00 end
Born to be Zerg
RobiTL
Profile Joined July 2010
France55 Posts
Last Edited: 2012-04-22 02:52:53
April 22 2012 02:15 GMT
#15
Ok I just wrote a PHP script that reads all the score values, which leaves build order and graph data to do !
Here is an output example :

+ Show Spoiler +

Array
(
[Player0] => Array
(
[Resources] => 28425
[Units] => 32725
[Structures] => 6100
[Overview] => 69300
[Average Unspent Resources] => 797
[Resource Collection Rate] => 1592
[Workers Created] => 70
[Units Trained] => 132
[Killed Unit Count] => 87
[Structures Built] => 63
[Structures Razed Count] => 0
[Spending Quotient] => 82.506486242342
)
[Player1] => Array
(
[Resources] => 31012
[Units] => 56625
[Structures] => 7000
[Overview] => 98487
[Average Unspent Resources] => 1495
[Resource Collection Rate] => 1949
[Workers Created] => 112
[Units Trained] => 252
[Killed Unit Count] => 85
[Structures Built] => 32
[Structures Razed Count] => 11
[Spending Quotient] => 77.608697996132
)
)


And here is the PHP script :
+ Show Spoiler +

<?php
$c = bin2hex(gzuncompress(file_get_contents($_GET['file'].'.s2gs', false, null, 16)));
$desc = array('Resources','Units','Structures','Overview','Average Unspent Resources','Resource Collection Rate','Workers Created','Units Trained','Killed Unit Count','Structures Built','Structures Razed Count');
for ($i = 0; $i < sizeof($desc); $i++)
{
$bleh = str_pad(base_convert($i * 2, 10, 16), 2, '0', STR_PAD_LEFT);
$search = '09ce0f0209'.$bleh.'02001e00';
$pos = strpos($c, $search) + strlen($search);
$found = 0;
for ($p = 0; $p <= 14; $pos += 2)
{
$hex = substr($c, $pos, 2);
if ($hex == '02')
{
$found = 1;
$after = strpos($c, '020400', $pos);
$value = substr($c, $pos + 10, $after - $pos - 10);
$v = 0;
for ($x = 0; $x*2 < strlen($value); $x++)
{
$dec = base_convert(substr($value, $x*2, 2),16,10);
if ($x == 0) $inc = $dec;
if ($x == 1) $inc = ($dec-1)*128;
if ($x == 2) $inc = ($dec-1)*16384;
$v += $inc;
}
$v = $v / 2;
$players['Player'.$p][$desc[$i]] = $v;
$pos = $after;
}
if ($hex == '00')
{
if ($found == 1) $found = 0;
else $p++;
}
}
}
foreach($players as $k => $v)
{
$i = $players[$k]['Resource Collection Rate'];
$u = $players[$k]['Average Unspent Resources'];
$players[$k]['Spending Quotient'] = 35*(0.00137*$i-log($u))+240;
}
echo '<pre>';
print_r($players);
echo '</pre>';
?>
Born to be Zerg
dsjoerg
Profile Joined January 2012
United States384 Posts
April 22 2012 02:20 GMT
#16
holy moly!
card-carrying grubby fan. developer of GGTracker.
BrothersCommunityTV
Profile Joined August 2011
Belgium13 Posts
April 22 2012 02:42 GMT
#17
Great job everyone
Torpedo.Vegas
Profile Blog Joined January 2011
United States1890 Posts
Last Edited: 2012-04-22 02:45:22
April 22 2012 02:44 GMT
#18
Now do it with all the files in SC2, find me more goodies!

P.S. Can and admin rename the SC2 forum "The Goodie Room" for few hours or so? lol
RobiTL
Profile Joined July 2010
France55 Posts
April 22 2012 02:53 GMT
#19
I just added the spending quotient to my script, edited on my previous post.
Born to be Zerg
zylog
Profile Joined August 2010
Canada943 Posts
April 22 2012 03:00 GMT
#20
This is awesome. I wonder if this can somehow be integrated into sc2gears to add additional information for replay analyses.
1 2 3 4 5 6 7 Next All
Please log in or register to reply.
Live Events Refresh
BeAsT Cup
17:00
qualifier#2 semi pro 5700
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 1477
IndyStarCraft 275
JuggernautJason 146
WinterStarcraft132
DisKSc2 70
CosmosSc2 52
StarCraft: Brood War
Mini 274
Soulkey 238
sSak 159
Dewaltoss 83
ZZZero.O 64
Sexy 35
Iris 2
Dota 2
Dendi5598
EternaLEnVy1453
Counter-Strike: Global Offensive
fl0m1726
DGminise50
Super Smash Bros
PPMD170
Heroes of the Storm
Liquid`Hasu681
Other Games
summit1g8666
Stewie2K8386
Day[9].tv1374
Beastyqt916
C9.Mang0733
ToD503
Fnx 440
Trikslyr176
Lowko86
febbydoto20
Organizations
Dota 2
BeyondTheSummit339
StarCraft 2
Esl_sc2166
ESL.tv166
Other Games
BasetradeTV95
StarCraft 2
TaKeTV 78
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 25 non-featured ]
StarCraft 2
• HorussTv 46
• gerald23 34
• Dystopia_ 12
• Response 4
• Gussbus
• iNuTV
• Poblha
• Migwel
• Alpha X_
• aXEnki
• Laughngamez YouTube
• intothetv
• LaughNgamez Trovo
• Kozan
• IndyKCrew
StarCraft: Brood War
• sscaitournament3
• STPLYoutube
• BSLYoutube
• AfreecaTV YouTube
Dota 2
• WagamamaTV1492
• iSHOKZ500
Other Games
• Scarra2458
• imaqtpie2222
• Day9tv1374
• Shiphtur955
Upcoming Events
BeoBash
4h 30m
FuturE vs Cham
Online Event
13h 30m
Theatre of Dreams
13h 30m
Clem vs ByuN
herO vs Reynor
herO vs ByuN
Reynor vs Clem
Reynor vs ByuN
herO vs Clem
1v1 Eternal Contest Tou…
15h 30m
1v1 Eternal Contest Tou…
15h 30m
ESPOT SC2 Circuit
1d 19h
BSL 2v2 ProLeague
1d 21h
ESL Pro Tour
2 days
Theatre of Dreams
2 days
Serral vs Solar
MaxPax vs Cure
Serral vs MaxPax
Solar vs Cure
Solar vs MaxPax
Serral vs Cure
New Worlds Map Contest:…
2 days
Bonyth vs Sziky
Hawk vs TerrOr
BoA vs MadiNho
OyAji vs SquaLL
[ Show More ]
BSL 2v2 ProLeague
2 days
PSISTORM Gaming Misc
2 days
ESL Pro Tour
3 days
ESL Pro Tour
4 days
Theatre of Dreams
4 days
BeAsT Cup
4 days
Sparkling Tuna Cup
5 days
OlimoLeague
5 days
BeAsT Cup
6 days
Liquipedia Results

Completed

DDS36: Sziky vs. Zhanhun
WTL 2022 Summer
Community Clash League S4
WePlay Academy League S5

Ongoing

GAN Race Survival Season 5
KCM Ladies Race Survival 2022 Season 3
ASL Season 14
KCM Race Survival 2022 Season 3
BSL Season 15: ChoboLeague
BSL Season 15: HasuLeague
Screw Me Up Bro
Luck Over Strength
FS Mania
CSL season 6 Summer Cup
STL37
LASL Season 14
Future Cup 5 (U18)
DSSL 15
StarClash 0818 CHN vs KOR
TSL 9
WardiTV Summer 2022
NGS Storm Division S5
ESL Challenger League S42 AP

Upcoming

Deathfate Pro League 4
CWCL Season 5
Deathfate Pro Team League 2
StarClash 0828 CHN vs KOR Week10
StarClash 0821 CHN vs KOR Week9
Hongtu Solo League S3
IEM Katowice 2023
HSC XXII
2022 GSL: ST 2
DH Masters Atlanta
2022 GSL S3: Code S
Gladiators' Cup
Heroes International
Heroes Int. - NA LC Qual.
Heroes Int. - NA Qual. 2
Heroes Int. - EU LC Qual.
Heroes Int. - EU Qual. 2
Heroes Int. - NA Qual. 1
Heroes Int. - EU Qual. 1
IEM Rio Major 2022
IEM Rio 2022: AME RMR
IEM Rio 2022: EU RMR B
IEM Rio 2022: EU RMR A
IEM Rio 2022: APAC RMR
ESL Challenger Melbourne 2022
ESL Pro League Season 16
ESL Challenger League S42 EU
ESL Challenger League S42 NA
BLAST Premier Fall Groups
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2022 TLnet. All Rights Reserved.