Jump to content
Sign in to follow this  

Recommended Posts

I thought it would be useful to get some stuff graphed for testing AI's.

Basically I added this to my AI so in this case it graphs the number of units that the AI has.


log("graph::units:" + gameState.getOwnEntities().filter(Filters.byClass("Unit")).length + ":" + gameState.getPlayerID() + ":" + gameState.timeElapsed);

units and gameState.getOwnEntities().filter(Filters.byClass("Unit")).length are what you would change. You can graph lots of stuff simultaneously (though you need to add more colors to the styles variable in the python script).

Then I wrote a quick and dirty python script to graph it using matplotlib (comes as part of scipy).


import re
import pylab as p

f = open('{path to logs folder}/mainlog.html', 'r')

log = f.read()

r = re.compile("graph\:\:\S+\:[0-9]+(\.[0-9]+)?")

vals = re.findall(r"graph\:\\S+)?\[0-9]+(\.[0-9]+)?)?\[0-9]+)?\[0-9]+(\.[0-9]+)?)?", log)

#print vals

a = {}
for i in vals:
key = i[0] + " Player " + i[3]
if not key in a:
a[key] = [[],[]]
a[key][0].append(i[1])
a[key][1].append(float(i[4])/1000.0)

f1 = p.figure()
p.grid()

count = 0
styles = styles = ['r-', 'g-', 'b-', 'k-', 'm-', 'r--', 'g--', 'b--', 'k--', 'm--', 'r:', 'g:', 'b:', 'k:', 'm:']
for key in a:
count += 1
p.plot(a[key][1], a[key][0], styles[count], label=key)

p.legend(loc='best')

f1.savefig("out.png")

And thus you get prettiness.

MKuPs.png

Share this post


Link to post
Share on other sites

We can also hook stuff into the rest of the simulation system for more fun. I spent a while trying to work out how to get the resources gathered stat in the AI and then realized that it would be dead easy to add some code to the statistics component.

Share this post


Link to post
Share on other sites

It's a simplified version of the Achievements Timeline from Age of Kings :)

So the graph suggests qBot reached a population of 300 in under 25 minutes?

Share this post


Link to post
Share on other sites

It's a simplified version of the Achievements Timeline from Age of Kings :)

So the graph suggests qBot reached a population of 300 in under 25 minutes?

We should put something like this in game at some point. Yes, I disabled the attack component though, normally stuff would have died much earlier.

Share this post


Link to post
Share on other sites

This looks cool, eventually it could be integrated in the final statistics and eventually made accessible also during the game in a dedicated panel.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...