Thread history

Fragment of a discussion from Talk:LiteRumble
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
No results

Check here =)

Skilgannon (talk)10:48, 25 November 2014

Here is the suggested patch. Note that image array now created in uint8 RGB space, since resulting png image is in RGB space as well. As result it removes unnecessary image manipulation, after the array is prepared.

Beware, I was not able to fully test it since I am missing database and google modules. But it should work fine.

Note that colorAPSvsKNPBI is not used in this script but probably needed for another python script responsible for a given bot stats.

--- BotCompare.py	2014-09-15 15:40:19.000000000 -0400
+++ BotCompare.new.py	2014-11-26 22:28:50.000000000 -0500
@@ -266,28 +266,34 @@
                 
                 out.append("</td><td rowspan=\"7\">")
                 enemyScores = pickle.loads(zlib.decompress(rumble.ParticipantsScores))
+                # RGB color model
+                # Default colors
+                # colorSurvival = (0,255,0)
+                # colorAPS = (255,0,0)
+                # colorAPSvsKNPBI = (0,0,255)
+                # Colors suggested at 
+                # http://ksrowell.com/blog-visualizing-data/2012/02/02/optimal-colors-for-graphs/
+                colorSurvival = (62,150,81)
+                colorAPS = (204,37,41)
+                colorAPSvsKNPBI = (57,106,177)
                 size = 169
-                a = numpy.empty((size+1,size+1,4), dtype=numpy.float32)
+                a = numpy.empty((size+1,size+1,3), dtype=numpy.uint8)
                 a[...,(0,1,2)]=255
                 for cp in commonList:
                     eScore = enemyScores.get(cp.Name,None)
                     if eScore:
-                        a[max(0,min(size,size-int(round((cp.A_APS - cp.B_APS + 50)*0.01*size)))),
-                          int(round(eScore.APS*0.01*size)),(0)]=0
+                        x = int(round(eScore.APS*0.01*size))
+                        y = max(0,min(size,size-int(round((cp.A_APS - cp.B_APS + 50)*0.01*size))))
+                        a[x,y,(0,1,2)] = colorAPS
                         
-                        a[max(0,min(size,size-int(round((cp.A_Survival - cp.B_Survival + 50)*0.01*size)))),
-                          int(round(eScore.APS*0.01*size)),(1)]=0
+                        y = [max(0,min(size,size-int(round((cp.A_Survival - cp.B_Survival + 50)*0.01*size))))
+                        a[x,y,(0,1,2)] = colorSurvival
 #                        if eScore.ANPP > 0 and b.NPP >= 0:
  #                           a[size-int(round(b.NPP*0.01*size)),int(round(eScore.ANPP*0.01*size)),(0,1)]=0
                 
-                b = Image.fromarray(a.astype("uint8"), "CMYK")
-                c = cStringIO.StringIO()
-                b = b.convert("RGB")
-                a = numpy.array(b)
-                a[(a == (0,0,0)).all(axis=2)] = (255,255,255)
                 a[size - int(round(.5*size)),...] = 127
-                a
-                b = Image.fromarray(a,"RGB")
+                b = Image.fromarray(a.astype("uint8"),"RGB")
+                c = cStringIO.StringIO()
                 b.save(c,format="png")
                 d = c.getvalue()
                 c.close()

Beaming (talk)04:37, 27 November 2014