-
Notifications
You must be signed in to change notification settings - Fork 1
/
terrantest.py
146 lines (132 loc) · 4.19 KB
/
terrantest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#from RBUT import *
#from zerg import *
from terran import *
from tools import *
#from Build import *
#Supply_Depot.__class__ = Housecls
#print type(Supply_Depot)
def TwoRax(simulator, t):
Q = []
P = [
(1, SCV),
(2, SCV),
(3, SCV),
(4, SCV),
(5, Supply_Depot),
(6, SCV),
(7, SCV),
(8, SCV),
(9, SCV),
(10, Barracks),
(11, SCV),
(12, SCV),
(13, Orbital_Command),
(14, Extra_Supplies),
(15.5, MULE),
(16, SCV),
(17, Supply_Depot),
(18, SCV),
(19, Marine),
(20, SCV),
(21, Marine),
(22, Marine),
(23, Barracks_Tech_Lab),
(24, Supply_Depot),
(25, Marauder),
(26, Barracks_Tech_Lab),
(27, Marine),
(28, Marauder),
(29, Marine),
(30, Marauder),
(31, Marauder),
(32, Marauder),
(33, Barracks)]
for it in P:
Q.append((it[0], Item(it[1], simulator)))
#Q.append((1,Item(Refinery, simulator)))
#Q.append((1,NumberItem(SCV, simulator, 'IDF')))
#Q.append((1,NumberItem(SCV, simulator, 4)))
#Q.append((2,Item(Refinery, simulator)))
#Q.append((3,Item(Supply_Depot, simulator)))
#Q.append((4,NumberItem(Barracks, simulator, 2)))
#Q.append((5,Item(Barracks_Tech_Lab, simulator)))
#Q.append((6,Item(Marauder, simulator)))
#Q.append((7,Item(Marine, simulator)))
#Q.append((8,Item(Marauder, simulator)))
#Q.append((9,Item(Marine, simulator)))
#Q.append((10,Item(Marauder, simulator)))
#Q.append((11,Item(Supply_Depot, simulator)))
#Q.append((6,Item(Orbital_Command, simulator)))
#Q.append((7,Item(Barracks, simulator)))
#Q.append((5.5, NumberItem(Marine, simulator, 4)))
#Q.append((8,Item(MULE, simulator)))
#Q.append((9,Item(Barracks_Tech_Lab, simulator)))
#Q.append((10,Item(Barracks_Tech_Lab, simulator, 5)))
#Q.append((11, NumberItem(Marauder, simulator, 'IDF')))
#Q.append((11,Item(Stimpack, simulator)))
#Q.append((9, NumberItem(SCV, simulator, 5)))
#Q.append((9,Combo([(1,NumberItem(SCV, simulator, 'IDF')), (2,NumberItem(Marine, simulator, 'IDF'))])))
PQ = pipeline(Q)
#q = []
#q.append((9, TimingItem(DummyItem(simulator), simulator, t+100)))
#q.append((11, NumberItem(Marine, simulator, 'IDF')))
#SQ = pipeline(q)
#return workflow([PQ, SQ])
return workflow([PQ])
#print TestBuild(TwoRax, SCV, SCV)
#print Marine.BuildingBusy, Marine.BuildingReq
#import sys
#sys.exit(0)
T = 0.
m = []
g = []
t = []
simulator = terran(460)
#simulator.restart()
print Extra_Supplies.number
build = TwoRax(simulator, 80)
def run(simulator, m, g, t):
m.append(simulator.mineral)
g.append(simulator.gas)
t.append(simulator.time)
build.make()
m.append(simulator.mineral)
g.append(simulator.gas)
t.append(simulator.time)
#if Barracks_Tech_Lab.number > 0:
#print Barracks.List
#print Barracks.number
if Orbital_Command.number > 0:
print 'Orbital_Command', Orbital_Command.List[0]
#print simulator.population, simulator.PopOcupied
#print simulator.Miner, simulator.GasMiner
#print Command_Center.number, Command_Center.occupied
#print Barracks.number, Barracks.occupied
#m.append(simulator.mineral)
#g.append(simulator.gas)
#t.append(simulator.queue[0][0])
#Hatchery.run()
#simulator.Mining()
simulator.mainloop(run, simulator, m, g, t)
#print 'by 5min, %i Zerglings were produced.' % Zergling.number
#print 'by 5min, %i Roachs were produced.' % Roach.number
#print 'by 5min, %i Banelings were produced.' % Baneling.number
#print 'by 5min, %i Drone were produced.' % Drone.number
#print 'by 5min, %i SCVs were produced.' % SCV.number
print 'by 5min, %i Marines were produced.' % Marine.number
#for log in simulator.log:
#if log[0] == Hatchery:
#print (log[2]+log[3], Drone.number)
import matplotlib
import matplotlib.pyplot as plt
from numpy import array
from plot import *
fig = plt.figure()
sp = fig.add_subplot(111)
for item in simulator.log:
plotlog(sp,item)
plt.xlabel('Time (s)')
plt.ylabel('Mineral, Gas')
plt.plot(t, m, color='blue')
plt.plot(t, g, color='red')
plt.show()