Arimaa Forum (http://arimaa.com/arimaa/forum/cgi/YaBB.cgi)
Arimaa >> Site Discussion >> Rate evolution curve and statistics ?
(Message started by: pago on Jul 17th, 2010, 7:10am)

Title: Rate evolution curve and statistics ?
Post by pago on Jul 17th, 2010, 7:10am

Hello,

As far as I know Arimaa site only allows to know the current ELO rate of a player.

Wouldn't it be possible to get a curve showing the evolution of a player during a period (for example the last two years) and other kind of statistics (for example the histogram of all player rate)

Title: Re: Rate evolution curve and statistics ?
Post by rbarreira on Jul 17th, 2010, 7:51am
It would definitely be possible because the game history contains the rating for both players before that game. So this data exists in the site's database.

Whether it will happen soon or not, I don't know. It's definitely a cool idea though.

If omar needs volunteers for certain programming tasks like this one, I might try helping (with no guarantees as to when it would be finished).

Title: Re: Rate evolution curve and statistics ?
Post by ocmiente on Jul 17th, 2010, 7:57am
It is certainly possible, and I would like to see that on the site as well.  

In the meantime, you can get these statistics for yourself by downloading the game history files and extracting the data you need.  I wanted to see my rating history recently, and did that.  

If you have a C# compiler, you might be able to use the same code I wrote:


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication1
{
class Program
{
 static void Main(string[] args)
 {
  string user = "user_id";
  string directory = "C:\\location\\of\\arimaa\\game\\files";
  DirectoryInfo di = new DirectoryInfo(directory);
  FileInfo[] rgFiles = di.GetFiles("*.txt");

  StreamWriter outFile = new StreamWriter(directory + "\\Summary.txt");

  foreach (FileInfo fi in rgFiles)
  {
   FileStream file = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
   StreamReader sr = new StreamReader(file);
   while (!sr.EndOfStream)
   {
    string line = sr.ReadLine();
    if (line.Contains(user))
    {
     string[] substrings = line.Split('\t');
     int rating = 0;
     if (substrings[3].Equals(user))
     {
      rating = System.Convert.ToInt32(substrings[9]);
     }
     if (substrings[4].Equals(user))
     {
      rating = System.Convert.ToInt32(substrings[10]);
     }

     string timestamp = (substrings[27].Split('['))[0];

     outFile.WriteLine(rating + "," + timestamp);
    }
   }
   file.Close();
  }

  outFile.Close();
 }
}
}


The 'user_id' string, and the 'C:\\location\\of\\arimaa\\game\\files' string have to be changed for this to work.  Output is csv to the Summary.txt file, which I imported into Excel to get the graphs I wanted.   For what I wanted, the code seemed to work, but I don't provide any warranties :)

Also, the Excel formula for converting the time stamp to a date is:

Code:
=(((B1/60)/60)/24)+DATE(1970,1,1)+(-5/24)

where 'B1' is the cell that contains the time stamp.  

The other trick is to get the graph to use the dates as the x axis data.  That isn't very straightforward, but it is possible.

Title: Re: Rate evolution curve and statistics ?
Post by omar on Jul 20th, 2010, 4:54pm
I had experimented with this a bit, but never got around to finishing it.

You can see what I have here:
http://arimaa.com/arimaa/gameroom/graphRatings.htm

It uses this web service to get the rating history:
http://arimaa.com/arimaa/gameroom/playerRatingHist.cgi?u=omar

You can replace 'omar' with other usernames to get that users rating history. It returns a JSON encoded string which is easy to work with in JavaScript.

u - username
rh - rating history array with each element having:
r - rating
id - game id
t - unix timestamp of game end time

The data was then graphed using some SVG libraries I found.

If anyone wants to try building on this, feel free to use the web service to get the data.

Title: Re: Rate evolution curve and statistics ?
Post by rbarreira on Jul 23rd, 2010, 12:22am
I can now use omar's web service + a small program I hacked together + Excel to chart a player's rating history throughout time.

For example, Fritzlein's chart:

http://i27.tinypic.com/2jg3w94.jpg

chessandgo:

http://i31.tinypic.com/2ptw5c8.jpg

bot_marwin:

http://i29.tinypic.com/11ih6xk.jpg

If anyone is interested in a particular user's chart I can post it here.

I'll try to get this working on php later on to provide a graph generator online.

Title: Re: Rate evolution curve and statistics ?
Post by Fritzlein on Jul 23rd, 2010, 12:42am
Sweet.  If that tool were available online I would definitely use it.

I might opt for a scatter plot instead of a line graph, though, with a dot for each game played, so that long periods of inactivity look like gaps rather than ropes.

Title: Re: Rate evolution curve and statistics ?
Post by rbarreira on Jul 23rd, 2010, 12:45am
I added your chart and chessandgo's to the post. I'll try different kinds of charts later :)

Title: Re: Rate evolution curve and statistics ?
Post by Tuks on Jul 23rd, 2010, 6:47am
can you post mine plz?

Title: Re: Rate evolution curve and statistics ?
Post by Hippo on Jul 23rd, 2010, 7:46am

on 07/23/10 at 06:47:32, Tuks wrote:
can you post mine plz?

Me too :)

Title: Re: Rate evolution curve and statistics ?
Post by rbarreira on Jul 23rd, 2010, 9:12am
Tuks:

http://i30.tinypic.com/xor6mx.jpg

Hippo:

http://i28.tinypic.com/alptux.jpg

Title: Re: Rate evolution curve and statistics ?
Post by Eltripas on Jul 23rd, 2010, 12:30pm
Do want, please.

Title: Re: Rate evolution curve and statistics ?
Post by Hippo on Jul 23rd, 2010, 12:36pm
Thanks ... seems to me it would be only small challenge for some our players (... leo?) to make link available to generate such graphs to .png.
Incorporate it to player Pages would be interesting.


on 07/23/10 at 12:30:46, Eltripas wrote:
Do want, please.

Yes especially your graph is one I want to see ... there should be visible kickoff started by our first game this January.


on 07/20/10 at 16:54:32, omar wrote:
I had experimented with this a bit, but never got around to finishing it.

You can see what I have here:
http://arimaa.com/arimaa/gameroom/graphRatings.htm

Yes the time coordinate replacing the game number is a big improvement. Just to incorporate the automatic generation (with isolated points as proposed by Fritz).

I have read the javascripts under graphRatings.htm. Especially wz_graphics.js is very helpfull. I would change line.js to make another kind of graph. It would plot just points in time coordinate and rating coordinate. So the interface giving both coordinates to the graph should be changed as well.

I am not used to javascript but something like:

Code:
/*

graph.js

This package is free software.
It is distributed under GPL - legalese removed,
it means that you can use this for any purpose,
but cannot charge for this software.
Any enhancements you make to this piece of code,
should be made available free to the general public!

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

points.js provides a simple mechanism to draw point graphs. It  uses
wz_jsgraphics.js  which is copyrighted by
Copyright (c) Balamurugan S, 2005. sbalamurugan @ hotmail.com

Usage:
var g = new point_graph();
g.add(x_name1, x_value1, y_name1, y_value1);
g.add(x_name2, x_value2, y_name2, y_value2);

g.render("canvas_name", "graph title");

//where canvas_name is a div defined INSIDE body tag
<body>
<div id="canvas_name" style="overflow: auto; position:relative;height:300px;width:400px;"></div>


*/

function point_graph()
{
this.y_values   = new Array();
this.x_values   = new Array();
this.x_max      = -64000; //MAX INT
this.x_min      = 64000; //MAX INT
this.y_max      = -64000; //MAX INT
this.y_min      = 64000; //MAX INT
this.x_maxname  = "MaxX";
this.x_minname  = "MinX";
this.y_maxname  = "MaxY";
this.y_minname  = "MinY";

this.add = function(x_name, x_value, y_name, y_value)
 {
  this.x_values.push(parseInt(x_value,10));
  this.y_values.push(parseInt(y_value,10));

  if(x_value > this.x_max)
  {  this.x_max = parseInt(x_value,10);
     this.x_maxname = x_name; }

  if(x_value < this.x_min)
  {  this.x_min = parseInt(x_value,10);
     this.x_minname = x_name; }

  if(y_value > this.y_max)
  {  this.y_max = parseInt(y_value,10);
     this.y_maxname = y_name; }

  if(y_value < this.y_min)
  {  this.y_min = parseInt(y_value,10);
     this.y_minname = y_name; }
 }

this.render = function(canvas, title)
 {
  var jg  = new jsGraphics(canvas);
  var h   = 260;
  var w   = 360;
  var labelht = 15;
  var labelwd = 40;
  // Draw markers
  var i;
  jg.setColor("black");
  for(i = 0 ; i <= 5 ; i++)
    {
     jg.drawLine(0,Math.round((h/5*i)),labelwd+w,Math.round((h/5*i)));
    }
  jg.drawString(this.y_maxname+"",4,0));
  jg.drawString(this.y_minname+"",4,h));

  for(i = 0 ; i <= 5 ; i++)
    {
     jg.drawLine(labelwd+Math.round((w/5*i)),0,labelwd+Math.round((w/5*i)),h+labelht);
    }
  jg.drawString(this.x_maxname+"",0,h+labelht));
  jg.drawString(this.x_minname+"",w,h+labelht));

  jg.setStroke(1);

  jg.setColor("blue");
  for(i = 0; i < this.x_values.length; i++)
     {
      var ydif = this.y_max-this.y_min;
      if (ydif==0) ydif=1; // 0/0 replaced by 0/1
      var xdif = this.x_max-this.x_min;
      if (xdif==0) xdif=1; // 0/0 replaced by 0/1
      var x = Math.round(w*(this.x_values[i]-this.x_min)/x_dif);
      var y = Math.round(h*(this.y_max-this.y_values[i])/y_dif);
      jg.fillEllipse(x+labelwd, y, 3, 3);
     }

  jg.setFont("Verdana", fnt,  Font.BOLD);
  jg.drawStringRect(title, 0, h+labelht<<1 + 4, w+labelwd, "right");
  jg.paint();
 }

}

Could work.
With modified showData() ... I don't know how to work with dates (and if the 5 hours should be really subtracted)

Code:
function showData(){
 var i;
 var rh = glob.resp[0].rh;
 var dt = ""
//  alert(rh[0].r);
 var g = new point_graph();

 for(i=0;i<rh.length;i++){
   // dt=((rh[i].t/60*60)-5)*24)+{1.1.1970}; ...
   g.add(dt,rh[i].t,rh[i].r+"",rh[i].r);
 }
 
 g.render("pointCanvas", "Rating history");
}

Title: Re: Rate evolution curve and statistics ?
Post by Janzert on Jul 23rd, 2010, 4:19pm
here is a really primitive grapher using the flot javascript graphing library.

http://arimaa.janzert.com/rating_plot/

Janzert

Title: Re: Rate evolution curve and statistics ?
Post by Hippo on Jul 23rd, 2010, 6:25pm

on 07/23/10 at 16:19:06, Janzert wrote:
here is a really primitive grapher using the flot javascript graphing library.

http://arimaa.janzert.com/rating_plot/

Janzert


Oh nicely done :) I could stop trying :)

Title: Re: Rate evolution curve and statistics ?
Post by Fritzlein on Jul 23rd, 2010, 9:28pm

on 07/23/10 at 16:19:06, Janzert wrote:
here is a really primitive grapher using the flot javascript graphing library.

http://arimaa.janzert.com/rating_plot/

Janzert

Wow, nicely done.  Your own ratings plot is one of the more intriguing ones.  Also rabbits' is quite unusual.

It takes a while to load the graph for bot_arimaazilla, but the result is interesting because is roughly tracks the history of game room rating inflation/deflation.  (Basically we have been stable.)  Bot_bomb2005P1's graph is somewhat less informative, because 3245 of its 8760 games were against just one opponent.

My own graph shows two times when I intentionally inflated my rating (to 2400 and then later to 2500) followed by rapidly letting it deflate to a more reasonable level after I reached my goal.  It's a bit embarrassing to be reminded how much I once cared about my rating, and what I did to pump it up.  Now I think my game room rating of 2500 is roughly accurate, or maybe a touch low.

Title: Re: Rate evolution curve and statistics ?
Post by Janzert on Jul 23rd, 2010, 10:41pm

on 07/23/10 at 21:28:19, Fritzlein wrote:
Wow, nicely done.  Your own ratings plot is one of the more intriguing ones.  Also rabbits' is quite unusual.


Obviously my 5 year break to simply study the game without playing it gave me a 3-400 point elo gain. Watch out next time I come back. :P

Janzert

Title: Re: Rate evolution curve and statistics ?
Post by Eltripas on Jul 24th, 2010, 12:00am

on 07/23/10 at 16:19:06, Janzert wrote:
here is a really primitive grapher using the flot javascript graphing library.

http://arimaa.janzert.com/rating_plot/



Janzert


Nice!, thanks for this

Title: Re: Rate evolution curve and statistics ?
Post by leo on Jul 24th, 2010, 5:30am
Good that everybody jumps into programming this :)
I was contemplating making an SVG grapher that you can zoom in and all things vector graphics has to offer, but that won't be until the new chat room is ready.

Title: Re: Rate evolution curve and statistics ?
Post by omar on Jul 29th, 2010, 3:46pm
Wow, thanks for making this Brian. I've downloaded the page and included it as a graph icon on the players profile. I wanted to do something like this for a long time. Thanks for your help.

I like Leo's idea of being able to zoom in and maybe even being able to click on the dots to open the game comments window. But until then, this will work just fine.

Title: Re: Rate evolution curve and statistics ?
Post by Fritzlein on Jul 29th, 2010, 6:58pm

on 07/29/10 at 15:46:39, omar wrote:
Wow, thanks for making this Brian. I've downloaded the page and included it as a graph icon on the players profile.

Great!  I just tried this and I love being able to get there from the player profile.  Teensy suggestion: put the graph Icon after the rating and RU instead of before.

Title: Re: Rate evolution curve and statistics ?
Post by knarl on Aug 3rd, 2010, 1:33am

on 07/29/10 at 15:46:39, omar wrote:
Wow, thanks for making this Brian. I've downloaded the page and included it as a graph icon on the players profile.


This is cool. It works fine on my linux box using chromium browser, but it's just a white box where the graph should be using IE8 in windows. Here is the error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Timestamp: Tue, 3 Aug 2010 06:28:44 UTC


Message: 'window.G_vmlCanvasManager' is null or not an object
Line: 554
Char: 17
Code: 0
URI: http://arimaa.com/arimaa/gameroom/graph/bh/rating_plot/jquery.flot.js

Cheers,
knarl.

Title: Re: Rate evolution curve and statistics ?
Post by omar on Aug 17th, 2010, 3:00pm
Seems that IE doesn't support the many of the HTML5 features yet, like canvas and video.

I'll post a message on the login page to let IE users know to use the FireFox or Chrome browser instead.

Title: Re: Rate evolution curve and statistics ?
Post by leo on Aug 17th, 2010, 4:43pm
Alternatively, people who want to stick to IE might try the beta version of IE9 which is said to support most HTML5 features -- and SVG or some Microsoft "version" of it, I hope there won't be another war of standards as was the case on Javascript.

Title: Re: Rate evolution curve and statistics ?
Post by Janzert on Aug 17th, 2010, 10:43pm
Omar, it looks like when you transferred the plotting page to arimaa.com the file excanvas.js did not get moved. This is required for IE compatibility. The easiest way to get it might be to download the flot library directly from http://code.google.com/p/flot/.

You might also want to replace all the javascript (.js) files with the minified (i.e. "compressed") versions in that package (.min.js). Just rename them to be the same as the current files.

Janzert

Title: Re: Rate evolution curve and statistics ?
Post by omar on Aug 18th, 2010, 5:41pm
Oh great; thanks for the link Brian. The rating graphs now work in IE as well.

Title: Re: Rate evolution curve and statistics ?
Post by Fritzlein on Aug 18th, 2010, 11:24pm
Thanks again for this feature, Janzert and Omar.  I have already gotten used to it being there, and I use it routinely.



Arimaa Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.