4
#Copyright (C) 2008 aes and FunnyMan3595
5
#This file is part of Endgame: Singularity.
7
#Endgame: Singularity is free software; you can redistribute it and/or modify
8
#it under the terms of the GNU General Public License as published by
9
#the Free Software Foundation; either version 2 of the License, or
10
#(at your option) any later version.
12
#Endgame: Singularity is distributed in the hope that it will be useful,
13
#but WITHOUT ANY WARRANTY; without even the implied warranty of
14
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
#GNU General Public License for more details.
17
#You should have received a copy of the GNU General Public License
18
#along with Endgame: Singularity; if not, write to the Free Software
19
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#This file is used to generate a visual representation of the tech tree using
25
from os.path import realpath
29
sys.path.insert(0, ".")
32
print "Run this from the main Singularity directory, as utils/make-tree.py"
38
l = (("Advanced ", "Adv "),
40
("Manipulation","Mnp"),
44
("Personal Identification","P-Id"))
45
for f,t in l: s = s.replace(f, t)
49
c = [ k/f for f,k in zip([1000, 86400, 24*60], c)]
50
s = ', '.join(['%s %s' % (g.to_money(k), label) for label,k in zip(["money", "CPU", "days"], c) if k])
51
return s and '\\n'+s or ''
53
j = dict([ (v[1],',fillcolor="#ffcccc"') for k,v in g.jobs.items() ])
55
f = file("techs.dot", 'w')
61
edge [arrowsize=0.75];
62
node [shape=record,fontname=FreeSans,fontsize=7,height=0.01,width=0.01
63
style=filled,fillcolor=white];
69
for l in sum([ [ '"%s"->"%s";' % (p,k)
70
for p in v.prerequisites ]
71
for k,v in g.techs.items() if k != "unknown_tech"],
79
for n,t in g.techs.items():
80
if n == "unknown_tech": continue
81
s = '"%s" [label="%s' % (n, abbr(n)) + cost(t.cost_left)
82
s += '"'+ j.get(n,'') + '];\n'
90
try: system("dot -Tpng -o techs.png techs.dot")
93
f = file('items.dot','w')
95
s = 'node [fillcolor="#ccccff"];\n'
100
for name,item in g.items.items():
101
if not item.prerequisites: continue
102
for pre in item.prerequisites:
104
s = '"%s" -> "%s-item"' % (pre, name)
108
s = '"%s-item" [label="%s\\n' % (name, name) + cost(item.cost) + '"];\n'
112
s = 'node [fillcolor="#99ffff"];\n'
117
for name,base in g.base_type.items():
118
if not base.prerequisites: continue
119
for pre in base.prerequisites:
121
s = '"%s" -> "%s-base"' % (pre, name)
125
s = '"%s-base" [label="%s\\n' % (name, name) + cost(base.cost) + '"];\n'
129
s = 'node [fillcolor="#aaffaa"];\n'
139
f.write('edge [arrowhead=empty,color="#0000FF"];\n')
141
f.write('edge [arrowhead=normal,color="#000000"];\n')
144
for name,loc in g.locations.items():
145
if not loc.prerequisites: continue
146
if "unknown_tech" in loc.prerequisites:
149
for pre in loc.prerequisites:
154
s = '"%s" -> "%s-loc"' % (pre, name)
158
s = '"%s-loc" [label="%s"];\n' % (name, name)
166
try: system("unflatten -l10 items.dot | dot -Tpng -o items.png")