Visualizing attack data (JSON)

intellixintellix Join Date: 2008-03-24 Member: 63950Members
edited June 2011 in NS2 General Discussion
Hey, had a little bit of a play with the JSON that was provided through twitter and this is what I've pretty much made as of now:

<a href="http://www.konoro.org/ns2/" target="_blank">http://www.konoro.org/ns2/</a>

Not quite sure how you want the data presented but this is what I've got at the moment. Can do a lot more in more time (Can imagine you want summary charts, pies and what not)

At the moment the the JSON data is what I extracted from the file and stored locally as I think there are security issues with JSON that require JSONP to access remotely... Tell me if I'm wrong.

In order for me to extract the data from the actual NS2 server the JSON response has to be wrapped in a function that I specify, like so:

<?php echo $_GET['jquerycallback'] . '(' + jsonData + ')' ?>

<a href="http://api.jquery.com/jQuery.getJSON/" target="_blank">http://api.jquery.com/jQuery.getJSON/</a>

Created using jQuery, head.js, PHP.js
«1

Comments

  • MOOtantMOOtant Join Date: 2010-06-25 Member: 72158Members
    Kill frequency map would be nicest.. There are not enough kills to show more than 0/black over most of the map but you can work around that.
  • intellixintellix Join Date: 2008-03-24 Member: 63950Members
    Added the total amount of kills for Marines/Aliens and a frequency
  • vlncvlnc Join Date: 2010-09-07 Member: 73921Members, Squad Five Blue
    whoo that's cool, thank you for sharing this.
  • Dalai-LamaDalai-Lama Join Date: 2002-11-20 Member: 9459Members, Constellation
    What lifetime means in the JSON ?
    The time in second the guy was alive before the kill ?

    And it should be nice if in that JSON we could have the time spent on the round, to make some cool graphs :)
  • jerkstoresupjerkstoresup Join Date: 2011-06-22 Member: 105840Members
    edited June 2011
    Round length can be roughly calculated using max minus min on "date".

    Might do some processing.js effects on this data later when I have some spare time.
  • kingmobkingmob Join Date: 2002-11-01 Member: 3650Members, Constellation
    <!--quoteo(post=1855333:date=Jun 22 2011, 08:12 AM:name=intellix)--><div class='quotetop'>QUOTE (intellix @ Jun 22 2011, 08:12 AM) <a href="index.php?act=findpost&pid=1855333"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Hey, had a little bit of a play with the JSON that was provided through twitter and this is what I've pretty much made as of now:

    <a href="http://www.konoro.org/ns2/" target="_blank">http://www.konoro.org/ns2/</a><!--QuoteEnd--></div><!--QuoteEEnd-->

    Interesting first stab.
    I am more interested in the weapon usage.

    for instance I use Chrome for a browser.
    When I use the Page Find functionality It shows yellow bars in the scrollbar where that term is found.

    If you have chrome try the following:
    Rifle
    Shotgun
    Sentry
    Hydra

    I see that Rifle usage is low .... Shotgun usage is high.
    Sentries are everywhere.
    Hydras are more an annoyance than being deadly. (they mostly justt get killed)
  • intellixintellix Join Date: 2008-03-24 Member: 63950Members
    You could even go as far as to seperate the kills/deaths with each weapon equipped for each race
  • xVisionsxVisions Join Date: 2009-07-03 Member: 68021Members
    edited June 2011
    Im sure my performance is skewing the marine kills, die aliens die. hehehehhehe
  • MurphyIdiotMurphyIdiot NS2 programmer Join Date: 2008-04-17 Member: 64095Members, Super Administrators, NS2 Developer, Subnautica Developer, Pistachionauts, Future Perfect Developer
    <!--quoteo(post=1855372:date=Jun 22 2011, 08:11 AM:name=Dalai-Lama)--><div class='quotetop'>QUOTE (Dalai-Lama @ Jun 22 2011, 08:11 AM) <a href="index.php?act=findpost&pid=1855372"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->What lifetime means in the JSON ?
    The time in second the guy was alive before the kill ?

    And it should be nice if in that JSON we could have the time spent on the round, to make some cool graphs :)<!--QuoteEnd--></div><!--QuoteEEnd-->

    Yeah, it is the amount of time in seconds the target was alive before getting killed.

    The round times are stored in the end game stats (although access to that data needs to be improved).

    I am new to all this web stuff like JSON but I'll refine the access over time to best suit everyone. It is a delicate balance with this much data since we are using Google App Engine and would rather not spend a lot of money on kill stats ;)

    Oh, that reminds me. There is a 10 min delay on these stats so I could take advantage of App Engine's memcache so every request didn't hit the datastore. Also, I can eventually make it so all the stats are available (instead of the last 500 events per map, per version) with "pages" of data (1000 datastore entity limit per query on App Engine).

    I'll monitor this thread so just post if you have any questions!
  • rmarxrmarx Join Date: 2010-03-20 Member: 71020Members
    @MurphyIdiot: If you're really that worried about too much requests, you could ask the community to do some caching too.

    It would be quite easy to make a PHP script or something that downloads the data once every x hours, but just once, and stores it in the local database. If some community members then use this script and make public their server URLs where we can find the data, it will spread the load across multiple community-provided servers, only requiring 1 access every x hours (if 1 community server does this, the other servers can just update from that first one instead of from the google appengine).

    To make this user friendly, you could make sure your JSON url redirects to 1 of the known community servers randomly (even with checking of which servers are up etc.) so everyone can just keep using this single URL. You can then later use this kind of system for other kinds of data distribution as well.

    Maybe it's overkill, but it's quite easy to set something like this up (I could help if you want) and I'm sure there would be some community support, as it wouldn't cost that much traffic for the caching webservers either.


    @OP: looks nice, but maybe you can make it so that there are kind of categories or at least pages instead of everything on 1 very long page? Keep up the good work!
  • WilsonWilson Join Date: 2010-07-26 Member: 72867Members
    I'd love to see graphs showing, weapon kills (to see what weapons are killing the most), deaths (to see what classes are dying the most) and average life time by team and class.
  • MurphyIdiotMurphyIdiot NS2 programmer Join Date: 2008-04-17 Member: 64095Members, Super Administrators, NS2 Developer, Subnautica Developer, Pistachionauts, Future Perfect Developer
    <!--quoteo(post=1855471:date=Jun 22 2011, 01:04 PM:name=rmarx)--><div class='quotetop'>QUOTE (rmarx @ Jun 22 2011, 01:04 PM) <a href="index.php?act=findpost&pid=1855471"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->@MurphyIdiot: If you're really that worried about too much requests, you could ask the community to do some caching too.<!--QuoteEnd--></div><!--QuoteEEnd-->

    I am going to wait and see if we are hitting any limits over the week 180 goes out before making any decisions like this. Thanks for the ideas though!
  • FlashFlash Join Date: 2002-10-31 Member: 1783Members, Constellation
    edited June 2011
    So it's not just me that finds it hard to hit anything with the rifle then :D

    Attacker weapon type counts

    <a href="http://imgur.com/b2WCo" target="_blank"><img src="http://i.imgur.com/b2WCo.jpg" border="0" class="linked-image" /></a>

    Lifetimes

    <a href="http://imgur.com/JrOtA" target="_blank"><img src="http://i.imgur.com/JrOtA.jpg" border="0" class="linked-image" /></a>
  • elodeaelodea Editlodea Join Date: 2009-06-20 Member: 67877Members, Reinforced - Shadow
    away with those sentries!! >< 15%?!
  • SteinhauerSteinhauer Join Date: 2010-07-17 Member: 72493Members
    Obviously much more data is needed to really determine anything, but very cool statistics nonetheless!
  • MOOtantMOOtant Join Date: 2010-06-25 Member: 72158Members
    <!--quoteo(post=1855579:date=Jun 23 2011, 03:33 AM:name=elodea)--><div class='quotetop'>QUOTE (elodea @ Jun 23 2011, 03:33 AM) <a href="index.php?act=findpost&pid=1855579"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->away with those sentries!! >< 15%?!<!--QuoteEnd--></div><!--QuoteEEnd-->
    Why would you make any conclusions based on statistic sample of size 20? It's also all on summit.
  • TheckTheck Join Date: 2010-02-17 Member: 70611Members
    edited June 2011
    I've been playing a litle bit with the JSON data and some jQuery plugins and I've done this: <a href="http://ns2.theck.es/" target="_blank">http://ns2.theck.es/</a>

    I'ts a table that loads the data (now from a static file, loading the page with JSONP gives me an error) and lets you read it in an easier way.

    Also you can filter it by any field. The filters are dropdown for "fixed" data (I've tried to read all the data to make the selects but fails too xD) and text inputs for fields like coordinates, they found any value that contains what you fill in it.

    I Hope it's usefull for something xD
  • MurphyIdiotMurphyIdiot NS2 programmer Join Date: 2008-04-17 Member: 64095Members, Super Administrators, NS2 Developer, Subnautica Developer, Pistachionauts, Future Perfect Developer
    Nice work Theck!

    I was sorting by attacker weapon which is pretty interesting.

    I only heard of this JSONP thing a couple days ago so I'll try to fix the feeds soon so they work with it. I also want to add "pages" of data or something so all the data is available through multiple queries (1000 entity limit per query for App Engine).
  • WilsonWilson Join Date: 2010-07-26 Member: 72867Members
    Just a note, part of the reason for skulk bite being the top for "kills" is because of the destruction of power nodes and buildings. Not because the skulks are killing loads of marines.
  • MurphyIdiotMurphyIdiot NS2 programmer Join Date: 2008-04-17 Member: 64095Members, Super Administrators, NS2 Developer, Subnautica Developer, Pistachionauts, Future Perfect Developer
    Good point Wilson.

    We can filter the data by what the Skulk bite is killing (Marines only) to get a better idea on it's effectiveness.
  • CoolCookieCooksCoolCookieCooks Pretty Girl Join Date: 2003-05-18 Member: 16446Members, NS1 Playtester, Contributor, Constellation
    I notice in Flash's pie chart there is death by "Marine", how is this possible? Roundhouse kick marines coming into fashion?
  • kingmobkingmob Join Date: 2002-11-01 Member: 3650Members, Constellation
    I would agree the attacker weapon stuff is fascinating.

    seems flamethrower loves skulks more than fades and DI
  • NolSinklerNolSinkler On the Clorf Join Date: 2004-02-15 Member: 26560Members, Constellation
    Am I the only one, when I click on the link, to get "NS2 Attack Data" and then "loading..." but it never loads?
  • ZurikiZuriki Join Date: 2010-11-20 Member: 75105Members
    edited June 2011
    <!--quoteo(post=1855829:date=Jun 23 2011, 07:28 PM:name=CoolCookieCooks)--><div class='quotetop'>QUOTE (CoolCookieCooks @ Jun 23 2011, 07:28 PM) <a href="index.php?act=findpost&pid=1855829"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->I notice in Flash's pie chart there is death by "Marine", how is this possible? Roundhouse kick marines coming into fashion?<!--QuoteEnd--></div><!--QuoteEEnd-->
    Suicide?

    More interesting are the "MAC" kills.
  • FlashFlash Join Date: 2002-10-31 Member: 1783Members, Constellation
    This is a breakdown of what each weapon is killing and what each unit is being killed by. Hope it's not too difficult to read.

    [attachment=35998:death_br...down_ns2.html]
  • LornathLornath Join Date: 2002-11-30 Member: 10280Members
    Here's a very basic death heatmap for Summit:

    <a href="http://ve.ihopeitworks.com/ns2/summit_heatmap.html" target="_blank">http://ve.ihopeitworks.com/ns2/summit_heatmap.html</a>
  • TheckTheck Join Date: 2010-02-17 Member: 70611Members
    <!--quoteo(post=1855801:date=Jun 23 2011, 06:01 PM:name=MurphyIdiot)--><div class='quotetop'>QUOTE (MurphyIdiot @ Jun 23 2011, 06:01 PM) <a href="index.php?act=findpost&pid=1855801"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Nice work Theck!

    I was sorting by attacker weapon which is pretty interesting.

    I only heard of this JSONP thing a couple days ago so I'll try to fix the feeds soon so they work with it. I also want to add "pages" of data or something so all the data is available through multiple queries (1000 entity limit per query for App Engine).<!--QuoteEnd--></div><!--QuoteEEnd-->
    The error that gaves me Chrome is: "Resource interpreted as Script but transferred with MIME type text/html."

    I supose you need to put something like if you use PHP:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->header('Content-type: text/javascript');<!--c2--></div><!--ec2-->
  • NurEinMenschNurEinMensch Join Date: 2003-02-26 Member: 14056Members, Constellation
    <!--quoteo(post=1856023:date=Jun 24 2011, 11:00 AM:name=Lornath)--><div class='quotetop'>QUOTE (Lornath @ Jun 24 2011, 11:00 AM) <a href="index.php?act=findpost&pid=1856023"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Here's a very basic death heatmap for Summit:

    <a href="http://ve.ihopeitworks.com/ns2/summit_heatmap.html" target="_blank">http://ve.ihopeitworks.com/ns2/summit_heatmap.html</a><!--QuoteEnd--></div><!--QuoteEEnd-->

    That's very neat.
  • TheckTheck Join Date: 2010-02-17 Member: 70611Members
    Well, after talking with the <a href="http://www.naturalselection.es" target="_blank">Spanish Natural Selection community</a> team, I've moved my dinamic table of NS2 Stats to <a href="http://www.naturalselection.es/ns2-stats/" target="_blank">this section</a> of the site.

    I want to fix some problems with that version to merge better with the site and I want to add more features to it.
  • MurphyIdiotMurphyIdiot NS2 programmer Join Date: 2008-04-17 Member: 64095Members, Super Administrators, NS2 Developer, Subnautica Developer, Pistachionauts, Future Perfect Developer
    I fixed the content types on the end game and kill stats pages. They should be "application/json" for raw JSON data and "application/javascript" for JSONP.

    Just add in a callback to the URL and it will do JSONP. I tested locally with JQuery and it all seemed to work as far as I could tell. Pretty neat little hack this JSONP is.

    Let me know if there are other things I can do to make dealing with this data easier!
Sign In or Register to comment.