Hi,
after checking out your current SVN with the amd64-fixes and some
nostalgia-play, I was disappointed that the web tech trees out there
seem to only list what you have to research to get something in a
straight line. I needed an overview, so I created a little python tool
that parses the data files and, using graphviz, makes a nice graph.
http://beta.digital-trauma.de/media/techtree.svg
http://beta.digital-trauma.de/media/techtree.png
Thought you might be interested :-). Particulary because some of the
entries seem to be unused (the lonely boxes on the left).
Regards,
Thomas
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class Item(object):
"""An item of the tech tree"""
c = 1
def __init__(self, name =None, lname=None, deps=None):
Item.c += 1
if Item.c > 12: Item.c = 1
self.color = Item.c
self.deps = deps or []
self.lname = lname
self.name = name
self.desc = ""
def __str__(self):
return self.name
# IDs containing the first string will get the color given as second string
# ordered by decreasing priority
colorize = [
("R-Wpn-", "red"),
("R-Struc-Research-", "darkorange"),
("R-Defense-Wall", "grey"),
("R-Defense-", "darkgrey"),
("R-Cyborg-", "lightgreen"),
("R-Vehicle-", "darkgreen"),
("", "black"),
]
if __name__ == "__main__":
items = {}
print "Reading items..."
f = open("data/mp/stats/research/multiplayer/research.txt", "r")
for line in f:
l = line.split(",")
if len(l) == 20:
n = l[0]
items[n]=Item(n)
for marker, col in colorize:
if marker in n:
items[n].color=col
break
else:
print "Bad line %r"%line
print "Fetching desc..."
f = open("data/mp/messages/strings/resstrings.txt", "r")
lastitem = None
for line in f:
# line should look like '//identifier "Long Name"'
# then below follows 'SMTH_MSG2 "A really dangerous something"'
l = line.split(None, 1)
if len(l) == 2:
if l[0][:2] == "//" and l[0][2:] in items:
lastitem = items[l[0][2:]]
elif lastitem and l[0][-5:] == "_MSG2":
lastitem.desc=l[1][1:-2]
lastitem = None
print "Fetching Names..."
f = open("data/mp/messages/strings/names.txt", "r")
lastitem = None
for line in f:
# line should look like 'identifier "Long Name"'
l = line.split(None, 1)
if len(l) == 2:
if l[0] in items:
items[l[0]].lname = l[1].strip()[1:-1]
print "Building Tree..."
f = open("data/mp/stats/research/multiplayer/prresearch.txt", "r")
for line in f:
l = line.split(",")
if len(l) == 3:
n = l[0]
items[n].deps.append(l[1])
else:
print "Bad line %r"%line
print "Writing .dot..."
f = open("techtree.dot", "w")
f.write("digraph techtree {\n")
#f.write(' colorscheme="accent8";\n')
f.write(' fontname="Arial";\n')
f.write(' fontnames="ps";\n')
f.write(" rankdir=LR;\n")
f.write(" node [shape=box];\n")
for item in sorted(items.values(), key=lambda i: i.name):
if item.lname:
f.write(' "%s" [label="%s", color="%s"];\n'%(item.name, item.lname,item.color))
else:
print "Item without proper name:", item.name
for item in sorted(items.values(), key=lambda i: i.name):
for d in item.deps:
f.write(' "%s" -> "%s" [color=%s];\n'%(d,item.name,items[d].color))
f.write("}\n")
print "All done."_______________________________________________
Warzone-dev mailing list
[email protected]
https://mail.gna.org/listinfo/warzone-dev