-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
35 lines (29 loc) · 1020 Bytes
/
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
const app = {};
app.reloadAI = async function(parameters={}){
console.log(parameters)
if(app.intelligence) await app.intelligence.close();
delete require.cache[require.resolve('./intelligence')]; //Delete require() cache
let Intelligence = require('./intelligence');
app.intelligence = new Intelligence(app);
app.parameters = parameters;
await app.intelligence.init();
}
async function main(){
//Create web interface + communication
let Server = require('./server');
app.server = new Server(app);
app.server.init();
//Create logger
let Logger = require('./logger');
app.logger = new Logger(app);
let params = {};
if(process.argv.length == 3 && process.argv[2]=="start") {
params = { simulate: false, disableColisions: false, start: true };
}
//Create AI
app.reloadAI(params);
}
main();
var cleanExit = function() { process.exit() };
process.on('SIGINT', cleanExit); // catch ctrl-c
process.on('SIGTERM', cleanExit); // catch kill