• Log In
  • Register
  • Settings
TeamLiquid TeamLiquidPro Liquipedia TSL4 LiquidPoker
EDT 20:25
CEST 02:25
KST 09:25
  • Home
  • Forum
  • Streams
  • Liquipedia
  • Features
  • Store
  • WCS
  • StarCraft 2
  • Dota 2
  • Brood War
  • WCS Portal
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • Events
  • BarCraft
  • StarCraft 2
  • Dota 2
  • Brood War
  • League of Legends
  • Blogs
Featured News
Auction OSL - Ro32 Day 2 P…
Auction OSL - Day 1 Recap …
Auction OSL: Ro32 - Openin…
DH Summer Day 2 Photos
DH Summer SC2 Interviews
Community News
New Patch - Warp Prism buf…
ESL TV adds Shaun 'Apollo'…
WCS AM Season 2 to be run …
Confirmed Players at the M…
Defiler Tours #60, 61, 62 …
Alliance Wins DreamHack Su…
Major leaving Team 8
C Liquid Team News
Liquid Weekly Digest | June…
Zenio: Razer Replaypack of …
EG-TL vs Team Eight in Roun…
Dreamhack Summer Day 3: Sc2!
Fluff's Photoblog from Drea…
Sponsored Threads
New SC2Links Mobile App …
Gamers Wanted as Volunteer…
TL Advertising Features
C General
James Gandolfini Passes …
Bleach manga
Dating, how's your luck?
US Politics Megathread
Brazilian Protests Thread
C TL Community
TL.net Ten Commandments
[Toronto] eSports Canada P…
Happy Birthday Resource Th…
Happy birthday salle!
The Automated Ban List
C Fan Clubs
The IdrA Fanclub
Startale Curious Fanclub
C User Streams
[STREAM] FlatLine
KeSPA Pro Sson Streaming
C Tech Support
DIY Mouse Cord Holder - Ea…
The Haswell overclocking t…
Computer Build Resource Th…
horrible twitch lag since …
Teamliquid Monitor Thread
C SC2 General
New Patch - Warp Prism b…
WCS AM Season 2 to be ru…
[SPL] SPL 12-13 week 23…
How Do You Motivate Your…
INnoVation and Cakegirl
Confirmed Players at the…
C SC2 Tourneys
[WCS AM] Group G Challenge…
[RSL] Ritmix RSL V - Ro32 …
[HSC] HomeStory Cup VII po…
£400 SC2Improve Summer Lea…
[UK] epic.ELEVEN to host B…
C SC2 Strategy
The HotS Terran Help Me Th…
CatZ CC first counter - a …
ZvZ Transition Sheet
[Q] TvZ early pools on Kor…
Simple Questions Simple An…
C Custom Maps
[M] (2) TPW Aldaris Betrayal
[P] Semmo's Map Thread
[M] (2) Crux Haeundae
[M] (4) TPW Roadrunner
[A] Starbow
C Dota 2 General
General Discussion
BlackBerry sponsors Virt…
DotA 2 Team Recruitment …
Dota 2 QQ thread
The GOOD Moments in Dota
Inhouse Dota
C Dota 2 Tourneys
RaidCall EMS One Americas …
Dota 2 General LR thread
Liquid Pasture Community L…
[DreamHack] ASUS ROG Tourn…
Gamers Affect Dota 2 Tourn…
C Dota 2 Strategy
Simple Questions, Simple A…
[G] Dark Seer, the master …
On the stomping of pubs
Does Visage deserve to be …
Learning Weaver?
C BW General
No LAN ? O_o
"Your connection to Batt…
[SOSPA] Event Matches
[TLS2 Ro16 Predictions]
New Launcher for ICC and…
Nada's Body
C BW Tourneys
Defiler Tours #60, 61, 62 …
[CRTL] Finals: C Entus vs …
[DRTL] All-Star Game
China vs Korea: Movie vs F…
C Ranks Teamleague Season 1
C BW Strategy
Simple Questions, Simple A…
DragOn's BW strategy reboot
Practice Partner Thread
Tutorial videos for beginn…
C Sports & Games
The XBox One
2013 NBA Finals
Planetside 2
The Elder Scrolls Online
Confederations Cup 2013!
C League of Legends
[Patch 3.08: Aatrox Patch]…
[PSA] TeamLiquid LoL Pens,…
[LoL] [SFW] Random Pics & …
C LoL Tourneys
[NA LCS] Summer Week 2
[OGN] Champions Summer Qua…
[AMD-INVEN]GamExperience
C LoL Strategy
[Tricks] Warding
[Champion] Diana
Simple Questions, Simple A…
C Diablo 3
The: What is my item worth?
Diablo 3 Coming to Xbox 36…
Witch Doctor Discussion
C TL Mafia
Roulette Mini Mafia
PTP IV - Demon's Run
Miscellaneous/Multi-Purpos…
C Health & Fitness
Running Thread
The 2013 Weightlifting Pro…
Olympic Weightlifting Thread
C Featured Blogs
Voice
thedeadhaji
WC3 Power Ranks!
monk
E3 2013
kierpanda
Sketch: Tap Out To…
Raihn
Liquid at D…
Liquid`FLUFF
C Blogs
Frustration and No…
playa
Quod Erat Dem…
Shiverfish
Dreamhack Summer…
Teodice
Theodicy and Mi…
Jerubaal
Les 24 Heures d…
HotShizz
Chilled Gaming M…
DJWilma
ISO Phil…
KING CHARLIE :D
The Grave Tempest…
gaymon
Leta - Movie
Michael - skyline
Anytime - Beast
By.Hero - Shuttle
Anytime - Pusan
Customize Sidebar...

Website Feedback

Closed Threads


IRC Web Chat

TeamSpeak 3 (75 users)


Active: 6099 users

s2gs file -- a fun little mystery for us

Forum Index > StarCraft 2 1 2 3 4 5 6 7 Next All
 
 dsjoerg   United States. April 21 2012 06:00. Posts 323
Profile # 
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
Old Post

 
 Kralic   Canada. April 21 2012 06:04. Posts 2569
Profile Blog # 
I am not sure what to say... so I will say good luck decrypting the encrypted file.
Brood War forever!
Old Post

 
 Monokeros   United States. April 21 2012 06:04. Posts 2469
Profile Blog # 
This would be all kinds of amazing seeing this kind of information more power to you sir.
Keep the Dream Alive
Old Post

 
 GGzerG   United States. April 21 2012 06:07. Posts 3542
Profile Blog # 
Sounds interesting but I don't even understand what you are saying to be honest, hope it works out for you.
http://cafe.daum.net/everguild @ Fish... ~Fish SPECIAL LEAGUE CHAMPIONS! :) *RIP Violet, RIP n.Die_aSam*
Old Post

 
 spancho   United States. April 21 2012 06:15. Posts 159
Profile # 

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
Old Post

 
 dsjoerg   United States. April 21 2012 06:19. Posts 323
Profile # 
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
Old Post

 
 InfCereal   Canada. April 21 2012 06:21. Posts 513
Profile # 

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.
 
Old Post

 
 netherh   United Kingdom. April 21 2012 22:05. Posts 274
Profile Blog # 
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.
Last edit: 2012-04-21 22:07:00
Old Post

 
 Prillan   Sweden. April 21 2012 22:19. Posts 149
Profile # 
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
"Reality is frequently inaccurate." - Douglas Adams
Old Post

 
 zyce   United States. April 21 2012 22:30. Posts 441
Profile Blog # 
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.
Last edit: 2012-04-21 22:32:46
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.
Old Post

 
 zyce   United States. April 21 2012 23:20. Posts 441
Profile Blog # 
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.
Old Post

 
 RobiTL   France. April 22 2012 02:05. Posts 55
Profile # 
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
Old Post

 
 dsjoerg   United States. April 22 2012 06:30. Posts 323
Profile # 
I believe the s2gs file is actually the concatenation of a few different logical files.
card-carrying grubby fan
Old Post

 
 RobiTL   France. April 22 2012 09:23. Posts 55
Profile # 
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
Last edit: 2012-04-22 09:54:05
Born to be Zerg
Old Post

 
 RobiTL   France. April 22 2012 11:15. Posts 55
Profile # 
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>';
?>
Last edit: 2012-04-22 11:52:53
Born to be Zerg
Old Post

 
 dsjoerg   United States. April 22 2012 11:20. Posts 323
Profile # 
holy moly!
card-carrying grubby fan
Old Post

 
 BrothersCommunityTV   Belgium. April 22 2012 11:42. Posts 13
Profile # 
Great job everyone
Old Post

 
 Torpedo.Vegas   United States. April 22 2012 11:44. Posts 1848
Profile Blog # 
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
Last edit: 2012-04-22 11:45:22
 
Old Post

 
 RobiTL   France. April 22 2012 11:53. Posts 55
Profile # 
I just added the spending quotient to my script, edited on my previous post.
Born to be Zerg
Old Post

 
 zylog   Canada. April 22 2012 12:00. Posts 941
Profile # 
This is awesome. I wonder if this can somehow be integrated into sc2gears to add additional information for replay analyses.
Old Post

1 2 3 4 5 6 7 Next All
Please log in or register to reply.
 
Refresh
 Calendar - June 
Th Fr Sa Su Mo Tu We
20212223242526
FEATURED ON AIR:
Wiki
[WCS AM] Group G CL
Stream: WCS_America
ON AIR:
→
LO3 - E163
Stream: OneMoreGame
→
[URTL] PrOp vs Glory
Stream: UR Gaming TV
Upcoming events:  [ More ]
36mESPORTS Mafia E09
36m[URTL] iMp vs oSp…
1h 36mRules of Engagement
2h 6mWedNightSprites #2…
2h 36mMeta: Episode #9
8h 36m[OSL] RO32 Group C&D
10h 36mHSC VII Day 1
11h 36mASL Ro64
11h 36m[DSL] iG vs LGD.int
15h 36m[EMS One] Group B
16h 36mAdroits #RC #3
16h 36mGo4SC2 #293
21h 36m[WCS AM] Group E CL
22h 36m[URTL] Denial vs…
1d[URTL] FXO.NA vs Op
1d 1hRules of Engagement
1d 8h[GSTL] Ax-Acer vs.…
1d 10hHSC VII Day 2
1d 16hXilence Cup 8
1d 21h[WCS AM] Group D
2 daysVengeance Cup Qual…
2 days[GSTL] AZUBU vs. FXO
2 daysMST#07
2 daysWyN Master CUP
2 daysHSC VII Day 3
2 daysAdroits RC #4
2 daysDenver June HOTS T…
2 daysSSRO #3
2 daysZOTAC NA #107
3 days[AlienwareCup]Grou…
3 days[BW] Defiler Tour…
3 daysHSC VII Day 4
3 daysGo4SC2 Sun €150
3 daysZOTAC EU #162
4 days[AlienwareCup]Grou…
5 days[OSL] RO32 Group E&F
5 days[AlienwareCup]Grou…
6 days[AlienwareCup]Grou…
Refresh
StarCraft: Brood War
snipealot2
dRaW
StarCraft 2
EG.iNcontroL [RC]
Spanishiwa
Dota 2
Merlini
Liquid`FLUFF
N0tail
Liquid`TC
Trixi
Other Notable Streams
Tobi Wan Kenobi
Destiny
PainUser
[ Show 100 non-featured ]
StarCraft: Brood War
• idenieide
• i am plus
• Archaeo
• tonight
StarCraft 2
• Anoss
• avilo
• AltWinter
• Tyraxus
• supremaciasc
• imarinetv
• hazuki
• sinvicta
• musti20045
• cheeseheadlogic
• JuggernautJason
• Chicks
• eNjiin
• BlordSc2
• confusid
• jglitch
• RuFF_SC2
• FXOkaRmy
• Jardozer
• SoOJuuu
• WonderSC2
• Dracorath
• SC2SCommunity
• iamhope
• jayaiwhy
• Bop
• Lingboy
• 0Toph
• nickcode
• TheBatman
• Impactsc2
• Solacee
• GrafZelle
• Jank
• Gemini_19
• SKyLiNe_SC2
• Brolettuce
• Slayer-
• zanderfever.TV
• Loonish
• krnx
• ToXSiK
• Zren89
• Jamesmorgan
• DEGENERATECARDPLAYER
• Voltzor
• DerZerfetzer
• SacrificialprobE
• ReconCorporation
Dota 2
• ArenaGamingDota2
• FroggedTV
• americandotaleague
• t40r
• DB42
• Ler
• phone_microwave
• Incarnius
• D4RKCIDE
• --derp--
• KRF
• dotbeef
• NashBrdiges
• GosuDota
League of Legends
• Bubbadub
• nosinned
• Mezxxii
• Psyal
• GrayFox-
• B-Wong
• montev87
• Hemling
• YoUr_KiLLeR
• JDubbin
Diablo III
• LouisvuittonShini
Other Games
• SK.Testie
• GAFALLEN
• [TyRanT]TheViper
• Trump
• moxierawr
• ArtemisKnives
• rizeupgaming
• Drako7
• dnyceboy
• Treasoned
• Girit
• Shizzler
• Yoshi Kirishima
• Igbarash
• Laggy
• RenJ-69
• AGcomandyzo(toss)
• maRkySC2
• hugar
• Crusaders TV
• Warnipple
• Gooey

» Recent SC2 Results
» Premier SC2 Tournaments

1. Sen
2. Stephano
3. Socke
4. mOOnGLaDe
5. Nerchio
1. Life
2. Curious
3. RorO
4. Symbol
5. PartinG
Sidebar Settings...

The Little App Factory



The opinions expressed by our users do not reflect the official position of TeamLiquid.net or its staff.

Advertising | Jobs | Privacy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren. Ad tag: TF_US.
The contents of this webpage are copyright © 2002-2013 Teamliquid.net. All Rights Reserved