Jump to content

AI graphing


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

Link to comment
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.

Link to comment
Share on other sites

  • 3 months later...

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.

 Share

×
×
  • Create New...