-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
357 lines (291 loc) · 10.2 KB
/
main.js
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
// let mineralBot = require('mineralBot');
//let mineralManager = require('mineralManager');
let build = require('build');
let upgrade = require('upgrade');
let mine = require('mine');
let repair = require('repair');
let haul = require('haul');
let linkController = require('linkController');
let panicButton = require('panicButton');
let Spawn1 = require('Spawn1');
let Spawn2 = require('Spawn2');
let Spawn3 = require('Spawn3');
let Spawn4 = require('Spawn4');
let Spawn5 = require('Spawn5');
let Spawn6 = require('Spawn6');
let Spawn7 = require('Spawn7');
let Spawn8 = require('Spawn8');
let Spawn9 = require('Spawn9');
let Spawn10 = require('Spawn10');
let Spawn11 = require('Spawn11');
let Spawn12 = require('Spawn12');
// let colonist = require('colonist');
// let claim = require('claim');
// let killer = require('killer');
// let killerHealer = require('killerHealer');
// let voyager = require('voyager');
module.exports.loop = function() {
if (Game.cpu.bucket > 1000){
for (let name in Game.creeps) {
let creep = Game.creeps[name];
// if (creep.memory.role == undefined){
// creep.memory.role = 'voyager';
// creep.memory.arrived = true;
// creep.memory.intercept = true;
// }
if (creep.memory.role == 'mine') {
mine.run(creep);
// } else if (creep.memory.role == 'killer') {
// try{
// killer.run(creep);
// }catch(e){
// console.log(e.message);
// }
// } else if (creep.memory.role == 'killerHealer') {
// try{
// killerHealer.run(creep);
// }catch(e){
// console.log(e.message);
// }
// } else if (creep.memory.role == 'colonist') {
// try{
// colonist.run(creep);
// }catch(e){
// console.log(e.message);
// }
// } else if (creep.memory.role == 'claim') {
// try{
// claim.run(creep);
// }catch(e){
// console.log(e.message);
// }
// } else if (creep.memory.role == 'mineralBot') {
// try{
// mineralBot.run(creep);
// }catch(e){
// console.log(e.message);
// }
// } else if (creep.memory.role == 'mineralManager') {
// try{
// mineralManager.run(creep);
// }catch(e){
// console.log(e.message);
// }
} else if (creep.memory.role == 'upgrade') {
try{
upgrade.run(creep);
}catch(e){
console.log(e.message);
}
} else if (creep.memory.role == 'build') {
try{
build.run(creep);
}catch(e){
console.log(e.message);
}
} else if (creep.memory.role == 'repair') {
try{
repair.fixStuff(creep);
}catch(e){
console.log(e.message);
}
} else if (creep.memory.role == 'haul') {
try{
haul.run(creep);
}catch(e){
console.log(e.message);
}
// } else if (creep.memory.role == 'voyager') {
// try{
// voyager.run(creep);
// }catch(e){
// console.log(e.message);
// }
}
}
let timer = 5;
if (Memory.activeDefenseMode > 0){
timer = 1;
}
if (Game.time % timer == 0){
Memory.activeDefenseMode = 0;
let roomList = [
'E29S49', //1 L zk ul --- g - gh
'E31S41', //2 O o h --- oh
'E41S39', //3 H
'E39S49', //4 U
'E41S29', //5 Z
'E21S49', //6 K
'W19S17', //7 Z
'W19S39', //8 H
'W21S25', //9 L
'W19S27', //10 X
'E49S29', //11 K
'W23S11' //12 X
];
for (let x = 0; x < roomList.length; x++){
let thisRoom = Game.rooms[roomList[x]];
try{
panicButton.run(thisRoom);
}catch(e){
console.log(e);
}
try{
linkController.run(thisRoom);
}catch(e){
console.log(e);
}
}
//console.log(ActiveDefense: ' + Memory.activeDefenseMode + ' towerTimer: ' + timer);
}
if (Game.time % 10 == 0){
for (let name in Memory.creeps) {
if (!Game.creeps[name]) {
delete Memory.creeps[name];
}
}
try{
if (Game.spawns['1'].spawning == null){
Spawn1.run('1');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['2'].spawning == null){
Spawn2.run('2');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['3'].spawning == null){
Spawn3.run('3');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['4'].spawning == null){
Spawn4.run('4');
}
}catch(e){
console.log(e.message);
}
try{if (Game.spawns['5'].spawning == null){
Spawn5.run('5');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['6'].spawning == null){
Spawn6.run('6');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['7'].spawning == null){
Spawn7.run('7');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['8'].spawning == null){
Spawn8.run('8');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['9'].spawning == null){
Spawn9.run('9');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['10'].spawning == null){
Spawn10.run('10');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['Spawn11'].spawning == null){
Spawn11.run('Spawn11');
}
}catch(e){
console.log(e.message);
}
try{
if (Game.spawns['12'].spawning == null){
Spawn12.run('12');
}
}catch(e){
console.log(e.message);
}
console.log('Bucket: ' + Game.cpu.bucket);
// Memory.cpuCounter += 10;
// console.log('Average CPU used: ' + (Memory.cpuTotal / Memory.cpuCounter) + ' over the last ' + Memory.cpuCounter + ' ticks. ' +
// 'Bucket: ' + Game.cpu.bucket);
}
// if (Game.time % 100 == 0){
// Memory.cpuCounter = 0;
// Memory.cpuTotal = 0;
// console.log('Clearing CPU average');
// }
// Memory.cpuTotal += Game.cpu.getUsed();
} else {
console.log('Halting at ' + Game.cpu.bucket);
}
}
//collect droped minerals
//creep target to memory
//cpu time reports
//auto sell minerals
//combine build/repair
//one big miner
//remove decisions from creeps
//transmit simple actions to creeps
//better assault group
//kiting ranger
//upgraders simultaneous actions
//load level roles
//functions - return nearest energy etc
//build priority
//multi shard refactor
//better road repair
//find stuff intermittently
//notifications
//auto defenders/repairers
//generate more safe modes with 1000 g
//repo refactor
//save cpu time
//labs
//boosts
//upgrade from link
//colonist repair and deconstruct
//use findNearest maybe
//automate power harvesting
//creep counting from spawn name memory to room memory
//use free spawns
//mineral balancing
//auto market
//creep body builder
//creep destination coordination
//turrets sort lowest hp or healers
//better pathfinding
//recall outsiders
//war mode
//remote harvesting
//path flag chains
//multiple guard flags
//replace const sites
//try catch local
//market energy balance
//fleet build counter
//colonists upgrade to 2 before building spawn
//simultaneous actions